From d67a60c2231b1233b0ef1d285e8c5801faae1089 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 29 Oct 2014 12:14:14 +0100 Subject: [PATCH 1/4] removed TODO --- arangod/Aql/V8Expression.cpp | 5 ++--- arangod/Aql/V8Expression.h | 14 +++++++++++--- 2 files changed, 13 insertions(+), 6 deletions(-) diff --git a/arangod/Aql/V8Expression.cpp b/arangod/Aql/V8Expression.cpp index ac5b53520b..a9141b1fbd 100644 --- a/arangod/Aql/V8Expression.cpp +++ b/arangod/Aql/V8Expression.cpp @@ -44,10 +44,9 @@ using namespace triagens::aql; //////////////////////////////////////////////////////////////////////////////// V8Expression::V8Expression (v8::Isolate* isolate, - v8::Persistent func) + v8::Persistent func) : isolate(isolate), func(func) { - } //////////////////////////////////////////////////////////////////////////////// @@ -76,8 +75,8 @@ AqlValue V8Expression::execute (triagens::arango::AqlTransaction* trx, size_t const n = vars.size(); TRI_ASSERT(regs.size() == n); // assert same vector length - // TODO: only convert those variables to V8 that are actually used in the expression v8::Handle values = v8::Object::New(); + for (size_t i = 0; i < n; ++i) { auto varname = vars[i]->name; auto reg = regs[i]; diff --git a/arangod/Aql/V8Expression.h b/arangod/Aql/V8Expression.h index 9dd29fe889..a284cf90f7 100644 --- a/arangod/Aql/V8Expression.h +++ b/arangod/Aql/V8Expression.h @@ -82,10 +82,18 @@ namespace triagens { // --SECTION-- public variables // ----------------------------------------------------------------------------- - v8::Isolate* isolate; +//////////////////////////////////////////////////////////////////////////////// +/// @brief the isolate used when executing and destroying the expression +//////////////////////////////////////////////////////////////////////////////// + + v8::Isolate* isolate; + +//////////////////////////////////////////////////////////////////////////////// +/// @brief the compiled expression as a V8 function +//////////////////////////////////////////////////////////////////////////////// + + v8::Persistent func; - v8::Persistent func; - }; } From 773927cb4c9ca5de17d8a2c4ea4a932a89423a7e Mon Sep 17 00:00:00 2001 From: Frank Celler Date: Wed, 29 Oct 2014 12:18:17 +0100 Subject: [PATCH 2/4] added CC version to info block --- m4/configure.information | 3 +++ 1 file changed, 3 insertions(+) diff --git a/m4/configure.information b/m4/configure.information index 4febfc6f20..6ae2f0771d 100644 --- a/m4/configure.information +++ b/m4/configure.information @@ -44,6 +44,9 @@ AC_MSG_NOTICE([CXXFLAGS: ${CXXFLAGS}]) AC_MSG_NOTICE([LDFLAGS: ${LDFLAGS}]) AC_MSG_NOTICE([LIBS: ${LIBS}]) +CC_VERSION=`${CC} --version 2>&1` +AC_MSG_NOTICE([CC: ${CC_VERSION}]) + echo $FLAG_INFO | tr "|" "\n" | while read a; do if test "x$a" != "x"; then AC_MSG_NOTICE([$[]a]) From ca15e72b14fea4148cdc2b56ea408e23cd500ee7 Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 29 Oct 2014 12:33:10 +0100 Subject: [PATCH 3/4] fixed test --- arangod/Aql/Optimizer.cpp | 15 +++--- ...ql-optimizer-rule-distribute-in-cluster.js | 50 ++++++++++++++++--- 2 files changed, 50 insertions(+), 15 deletions(-) diff --git a/arangod/Aql/Optimizer.cpp b/arangod/Aql/Optimizer.cpp index 12a621b2a2..e45a4134e2 100644 --- a/arangod/Aql/Optimizer.cpp +++ b/arangod/Aql/Optimizer.cpp @@ -117,6 +117,7 @@ int Optimizer::createPlans (ExecutionPlan* plan, return TRI_ERROR_NO_ERROR; } + bool runOnlyRequiredRules = false; int leastDoneLevel = 0; TRI_ASSERT(! _rules.empty()); @@ -169,9 +170,10 @@ int Optimizer::createPlans (ExecutionPlan* plan, */ level = (*it).first; - if (disabledIds.find(level) != disabledIds.end() && + if ((runOnlyRequiredRules || disabledIds.find(level) != disabledIds.end()) && (*it).second.canBeDisabled) { - // we picked a disabled rule + // we picked a disabled rule or we have reached the max number of plans + // and just skip this rule level = it->first; _newPlans.push_back(p, level); // nothing to do, just keep it @@ -210,13 +212,12 @@ int Optimizer::createPlans (ExecutionPlan* plan, // std::cout << "Least done level is " << leastDoneLevel << std::endl; // Stop if the result gets out of hand: - if (_plans.size() >= _maxNumberOfPlans) { - // TODO: must iterate over all REQUIRED remaining transformation rules + if (! runOnlyRequiredRules && + _plans.size() >= _maxNumberOfPlans) { + // must still iterate over all REQUIRED remaining transformation rules // because there are some rules which are required to make the query // work in cluster mode - // rules that have their canBeDisabled flag set to false must still - // be carried out! - break; + runOnlyRequiredRules = true; } } diff --git a/js/server/tests/aql-optimizer-rule-distribute-in-cluster.js b/js/server/tests/aql-optimizer-rule-distribute-in-cluster.js index 77ffb28468..535ea4232c 100644 --- a/js/server/tests/aql-optimizer-rule-distribute-in-cluster.js +++ b/js/server/tests/aql-optimizer-rule-distribute-in-cluster.js @@ -43,6 +43,7 @@ function optimizerRuleTestSuite () { var rulesAll = { optimizer: { rules: [ "+all" ] } }; var thisRuleEnabled = { optimizer: { rules: [ "-all", "+" + ruleName ] } }; var thisRuleDisabled = { optimizer: { rules: [ "+all", "-" + ruleName ] } }; + var maxPlans = { optimizer: { rules: [ "-all" ] }, maxNumberOfPlans: 1 }; var cn1 = "UnitTestsAqlOptimizerRuleUndist1"; var cn2 = "UnitTestsAqlOptimizerRuleUndist2"; @@ -79,6 +80,43 @@ function optimizerRuleTestSuite () { db._drop(cn1); db._drop(cn2); }, + + //////////////////////////////////////////////////////////////////////////////// + /// @brief test that the rules fire even if the max number of plans is reached + //////////////////////////////////////////////////////////////////////////////// + + testThisRuleEnabledMaxNumberOfPlans : function () { + var queries = [ + "FOR d IN " + cn1 + " REMOVE d in " + cn1, + "FOR d IN " + cn1 + " REMOVE d._key in " + cn1, + "FOR d IN " + cn1 + " INSERT d in " + cn2, + "FOR d IN " + cn1 + " INSERT d._key in " + cn2 + ]; + + var expectedRules = [ + [ + "distribute-in-cluster", + "scatter-in-cluster", + ], + [ + "distribute-in-cluster", + "scatter-in-cluster" + ], + [ + "distribute-in-cluster", + "scatter-in-cluster" + ], + [ + "distribute-in-cluster", + "scatter-in-cluster" + ] + ]; + + queries.forEach(function(query, i) { + var result = AQL_EXPLAIN(query, { }, maxPlans); + assertEqual(expectedRules[i], result.plan.rules, query); + }); + }, //////////////////////////////////////////////////////////////////////////////// /// @brief test that the rule fires when it is enabled @@ -100,7 +138,6 @@ function optimizerRuleTestSuite () { [ "distribute-in-cluster", "scatter-in-cluster", - "distribute-filtercalc-to-cluster" ], [ "distribute-in-cluster", @@ -109,7 +146,6 @@ function optimizerRuleTestSuite () { [ "distribute-in-cluster", "scatter-in-cluster", - "distribute-filtercalc-to-cluster" ] ]; @@ -132,9 +168,9 @@ function optimizerRuleTestSuite () { "ScatterNode", "RemoteNode", "EnumerateCollectionNode", - "CalculationNode", "RemoteNode", "GatherNode", + "CalculationNode", "DistributeNode", "RemoteNode", "RemoveNode", @@ -159,9 +195,9 @@ function optimizerRuleTestSuite () { "ScatterNode", "RemoteNode", "EnumerateCollectionNode", - "CalculationNode", "RemoteNode", "GatherNode", + "CalculationNode", "DistributeNode", "RemoteNode", "InsertNode", @@ -375,7 +411,6 @@ function optimizerRuleTestSuite () { [ "distribute-in-cluster", "scatter-in-cluster", - "distribute-filtercalc-to-cluster", ], [ "distribute-in-cluster", @@ -384,7 +419,6 @@ function optimizerRuleTestSuite () { [ "distribute-in-cluster", "scatter-in-cluster", - "distribute-filtercalc-to-cluster", ] ]; @@ -407,9 +441,9 @@ function optimizerRuleTestSuite () { "ScatterNode", "RemoteNode", "EnumerateCollectionNode", - "CalculationNode", "RemoteNode", "GatherNode", + "CalculationNode", "DistributeNode", "RemoteNode", "RemoveNode", @@ -434,9 +468,9 @@ function optimizerRuleTestSuite () { "ScatterNode", "RemoteNode", "EnumerateCollectionNode", - "CalculationNode", "RemoteNode", "GatherNode", + "CalculationNode", "DistributeNode", "RemoteNode", "InsertNode", From 2d44778d40ce9e59c8f60f8c559daabde76ee0ad Mon Sep 17 00:00:00 2001 From: Jan Steemann Date: Wed, 29 Oct 2014 12:35:31 +0100 Subject: [PATCH 4/4] added CXX output --- m4/configure.information | 2 ++ 1 file changed, 2 insertions(+) diff --git a/m4/configure.information b/m4/configure.information index 6ae2f0771d..cab2deabeb 100644 --- a/m4/configure.information +++ b/m4/configure.information @@ -46,6 +46,8 @@ AC_MSG_NOTICE([LIBS: ${LIBS}]) CC_VERSION=`${CC} --version 2>&1` AC_MSG_NOTICE([CC: ${CC_VERSION}]) +CXX_VERSION=`${CXX} --version 2>&1` +AC_MSG_NOTICE([CXX: ${CXX_VERSION}]) echo $FLAG_INFO | tr "|" "\n" | while read a; do if test "x$a" != "x"; then