diff options
author | Andrii Dobroshynski <andrii.dobroshynski@mongodb.com> | 2021-06-17 15:24:21 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-06-17 16:44:38 +0000 |
commit | 20384afa5899fe742faf719a60f633fee1544d8a (patch) | |
tree | 3a844de65c2577cbc9e12139a4d209a945581579 | |
parent | 870f8af7b3052d0e866f3b24c7220fef1f9d66f5 (diff) | |
download | mongo-20384afa5899fe742faf719a60f633fee1544d8a.tar.gz |
SERVER-57758 Turn SBE off by default and invert the sense of the internalQueryForceClassicEngine flag
-rw-r--r-- | etc/evergreen.yml | 20 | ||||
-rw-r--r-- | etc/generate_subtasks_config.yml | 4 | ||||
-rw-r--r-- | jstests/libs/sbe_util.js | 9 | ||||
-rw-r--r-- | jstests/noPassthrough/query_knobs_validation.js | 4 | ||||
-rw-r--r-- | src/mongo/db/query/canonical_query.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/canonical_query.h | 8 | ||||
-rw-r--r-- | src/mongo/db/query/get_executor.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/query/plan_cache.cpp | 5 | ||||
-rw-r--r-- | src/mongo/db/query/plan_cache.h | 12 | ||||
-rw-r--r-- | src/mongo/db/query/plan_cache_test.cpp | 27 | ||||
-rw-r--r-- | src/mongo/db/query/query_knobs.idl | 7 | ||||
-rw-r--r-- | src/mongo/dbtests/query_stage_multiplan.cpp | 3 |
12 files changed, 56 insertions, 47 deletions
diff --git a/etc/evergreen.yml b/etc/evergreen.yml index c812aa201aa..4544e1aadd0 100644 --- a/etc/evergreen.yml +++ b/etc/evergreen.yml @@ -9246,15 +9246,15 @@ buildvariants: # distros: # - rhel80-large -- name: enterprise-rhel-80-64-bit-dynamic-classic-engine - display_name: "Shared Library Enterprise RHEL 8.0 (Classic Execution Engine)" +- name: enterprise-rhel-80-64-bit-dynamic-sbe-engine + display_name: "Shared Library Enterprise RHEL 8.0 (SBE Engine)" batchtime: 1440 # 1 day stepback: false modules: - enterprise run_on: - rhel80-small - expansions: &enterprise-rhel-80-64-bit-dynamic-classic-engine-expansions + expansions: &enterprise-rhel-80-64-bit-dynamic-sbe-engine-expansions additional_package_targets: archive-mongocryptd archive-mongocryptd-debug archive-mh archive-mh-debug compile_flags: --ssl MONGO_DISTMOD=rhel80 -j$(grep -c ^processor /proc/cpuinfo) --variables-files=etc/scons/mongodbtoolchain_v3_gcc.vars --link-model=dynamic multiversion_platform: rhel80 @@ -9269,7 +9269,7 @@ buildvariants: large_distro_name: rhel80-medium num_scons_link_jobs_available: 0.99 test_flags: >- - --mongodSetParameters="{internalQueryForceClassicEngine: true}" + --mongodSetParameters="{internalQueryEnableSlotBasedExecutionEngine: true}" --additionalFeatureFlags=featureFlagTimeseriesCollection tasks: - name: compile_test_and_package_parallel_core_stream_TG @@ -10947,8 +10947,8 @@ buildvariants: # - name: server_selection_json_test_TG - <<: *ubuntu1804-debug-asan-template - name: ubuntu1804-debug-asan-classic-engine - display_name: ~ ASAN Enterprise Ubuntu 18.04 DEBUG (Classic Execution Engine) + name: ubuntu1804-debug-asan-sbe-engine + display_name: ~ ASAN Enterprise Ubuntu 18.04 DEBUG (SBE Engine) modules: - enterprise run_on: @@ -10962,7 +10962,7 @@ buildvariants: san_options: LSAN_OPTIONS="suppressions=etc/lsan.suppressions:report_objects=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" ASAN_OPTIONS="detect_leaks=1:check_initialization_order=true:strict_init_order=true:abort_on_error=1:disable_coredump=0:handle_abort=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --allocator=system --sanitize=address --ssl --ocsp-stapling=off --enable-free-mon=on -j$(grep -c ^processor /proc/cpuinfo) test_flags: >- - --mongodSetParameters="{internalQueryForceClassicEngine: true}" + --mongodSetParameters="{internalQueryEnableSlotBasedExecutionEngine: true}" --excludeWithAnyTags=requires_fast_memory,requires_ocsp_stapling multiversion_platform: ubuntu1804 multiversion_edition: enterprise @@ -11174,8 +11174,8 @@ buildvariants: # - name: server_selection_json_test_TG - <<: *ubuntu1804-debug-ubsan-template - name: ubuntu1804-debug-ubsan-classic-engine - display_name: ~ UBSAN Enterprise Ubuntu 18.04 DEBUG (Classic Execution Engine) + name: ubuntu1804-debug-ubsan-sbe-engine + display_name: ~ UBSAN Enterprise Ubuntu 18.04 DEBUG (SBE Engine) modules: - enterprise run_on: @@ -11189,7 +11189,7 @@ buildvariants: san_options: UBSAN_OPTIONS="print_stacktrace=1:external_symbolizer_path=/opt/mongodbtoolchain/v3/bin/llvm-symbolizer" compile_flags: --variables-files=etc/scons/mongodbtoolchain_v3_clang.vars --dbg=on --opt=on --sanitize=undefined --ssl --ocsp-stapling=off --enable-free-mon=on -j$(grep -c ^processor /proc/cpuinfo) test_flags: >- - --mongodSetParameters="{internalQueryForceClassicEngine: true}" + --mongodSetParameters="{internalQueryEnableSlotBasedExecutionEngine: true}" --excludeWithAnyTags=requires_ocsp_stapling multiversion_platform: ubuntu1804 multiversion_edition: enterprise diff --git a/etc/generate_subtasks_config.yml b/etc/generate_subtasks_config.yml index c14fa99c7e9..6b835b8b79d 100644 --- a/etc/generate_subtasks_config.yml +++ b/etc/generate_subtasks_config.yml @@ -44,7 +44,7 @@ build_variant_large_distro_exceptions: - ubuntu1604-debug - ubuntu1804-debug-asan - ubuntu1804-debug-asan-all-feature-flags - - ubuntu1804-debug-asan-classic-engine + - ubuntu1804-debug-asan-sbe-engine - ubuntu1804-debug-ubsan - ubuntu1804-debug-ubsan-all-feature-flags - - ubuntu1804-debug-ubsan-classic-engine + - ubuntu1804-debug-ubsan-sbe-engine diff --git a/jstests/libs/sbe_util.js b/jstests/libs/sbe_util.js index 580fb8103f4..8728fabf191 100644 --- a/jstests/libs/sbe_util.js +++ b/jstests/libs/sbe_util.js @@ -32,10 +32,11 @@ function checkSBEEnabled(theDB) { continue; } - const getParam = - conn.adminCommand({getParameter: 1, internalQueryForceClassicEngine: 1}); - checkResult = getParam.hasOwnProperty("internalQueryForceClassicEngine") && - !getParam.internalQueryForceClassicEngine; + const getParam = conn.adminCommand( + {getParameter: 1, internalQueryEnableSlotBasedExecutionEngine: 1}); + checkResult = + getParam.hasOwnProperty("internalQueryEnableSlotBasedExecutionEngine") && + getParam.internalQueryEnableSlotBasedExecutionEngine; return true; } catch (e) { continue; diff --git a/jstests/noPassthrough/query_knobs_validation.js b/jstests/noPassthrough/query_knobs_validation.js index 81daf4af68f..0ff57fedb3e 100644 --- a/jstests/noPassthrough/query_knobs_validation.js +++ b/jstests/noPassthrough/query_knobs_validation.js @@ -192,8 +192,8 @@ assertSetParameterSucceeds("internalQuerySlotBasedExecutionMaxStaticIndexScanInt assertSetParameterFails("internalQuerySlotBasedExecutionMaxStaticIndexScanIntervals", 0); assertSetParameterFails("internalQuerySlotBasedExecutionMaxStaticIndexScanIntervals", -1); -assertSetParameterSucceeds("internalQueryForceClassicEngine", true); -assertSetParameterSucceeds("internalQueryForceClassicEngine", false); +assertSetParameterSucceeds("internalQueryEnableSlotBasedExecutionEngine", true); +assertSetParameterSucceeds("internalQueryEnableSlotBasedExecutionEngine", false); MongoRunner.stopMongod(conn); })(); diff --git a/src/mongo/db/query/canonical_query.cpp b/src/mongo/db/query/canonical_query.cpp index 602a1a8dcb1..3a28c93c36e 100644 --- a/src/mongo/db/query/canonical_query.cpp +++ b/src/mongo/db/query/canonical_query.cpp @@ -196,7 +196,7 @@ Status CanonicalQuery::init(OperationContext* opCtx, _findCommand = std::move(findCommand); _canHaveNoopMatchNodes = canHaveNoopMatchNodes; - _forceClassicEngine = internalQueryForceClassicEngine.load(); + _enableSlotBasedExecutionEngine = internalQueryEnableSlotBasedExecutionEngine.load(); auto validStatus = isValid(root.get(), *_findCommand); if (!validStatus.isOK()) { diff --git a/src/mongo/db/query/canonical_query.h b/src/mongo/db/query/canonical_query.h index 66877058389..457831e3b77 100644 --- a/src/mongo/db/query/canonical_query.h +++ b/src/mongo/db/query/canonical_query.h @@ -229,8 +229,8 @@ public: return _explain; } - bool getForceClassicEngine() const { - return _forceClassicEngine; + bool getEnableSlotBasedExecutionEngine() const { + return _enableSlotBasedExecutionEngine; } void setExplain(bool explain) { @@ -278,8 +278,8 @@ private: bool _explain = false; - // Determines whether the classic engine must be used. - bool _forceClassicEngine = false; + // Determines whether the SBE engine is enabled. + bool _enableSlotBasedExecutionEngine = false; }; } // namespace mongo diff --git a/src/mongo/db/query/get_executor.cpp b/src/mongo/db/query/get_executor.cpp index 383a872e180..d5d73fdf0f0 100644 --- a/src/mongo/db/query/get_executor.cpp +++ b/src/mongo/db/query/get_executor.cpp @@ -1203,7 +1203,7 @@ StatusWith<std::unique_ptr<PlanExecutor, PlanExecutor::Deleter>> getExecutor( std::unique_ptr<CanonicalQuery> canonicalQuery, PlanYieldPolicy::YieldPolicy yieldPolicy, size_t plannerOptions) { - return !canonicalQuery->getForceClassicEngine() && + return canonicalQuery->getEnableSlotBasedExecutionEngine() && isQuerySbeCompatible(opCtx, canonicalQuery.get(), plannerOptions) ? getSlotBasedExecutor( opCtx, collection, std::move(canonicalQuery), yieldPolicy, plannerOptions) diff --git a/src/mongo/db/query/plan_cache.cpp b/src/mongo/db/query/plan_cache.cpp index 4544c82ed02..945e4e98c6e 100644 --- a/src/mongo/db/query/plan_cache.cpp +++ b/src/mongo/db/query/plan_cache.cpp @@ -690,8 +690,9 @@ PlanCacheKey PlanCache::computeKey(const CanonicalQuery& cq) const { StringBuilder indexabilityKeyBuilder; encodeIndexability(cq.root(), _indexabilityState, &indexabilityKeyBuilder); - return PlanCacheKey( - std::move(shapeString), indexabilityKeyBuilder.str(), cq.getForceClassicEngine()); + return PlanCacheKey(std::move(shapeString), + indexabilityKeyBuilder.str(), + cq.getEnableSlotBasedExecutionEngine()); } StatusWith<std::unique_ptr<PlanCacheEntry>> PlanCache::getEntry(const CanonicalQuery& query) const { diff --git a/src/mongo/db/query/plan_cache.h b/src/mongo/db/query/plan_cache.h index e7db19047ab..161a5ed9697 100644 --- a/src/mongo/db/query/plan_cache.h +++ b/src/mongo/db/query/plan_cache.h @@ -51,11 +51,11 @@ class PlanCacheKey { public: PlanCacheKey(CanonicalQuery::QueryShapeString shapeString, std::string indexabilityString, - bool forceClassicQueryEngine) { + bool enableSlotBasedExecution) { _lengthOfStablePart = shapeString.size(); _key = std::move(shapeString); _key += indexabilityString; - _key += forceClassicQueryEngine ? "t" : "f"; + _key += enableSlotBasedExecution ? "t" : "f"; } CanonicalQuery::QueryShapeString getStableKey() const { @@ -100,10 +100,10 @@ public: private: // Key is broken into three parts: - // <stable key> | <indexability discriminators> | <forceClassicQueryEngine boolean> - // This third part can be removed once the classic query engine reaches EOL. - // Combined, the three parts make up the plan cache key. We store them in one std::string so - // that we can easily/cheaply extract the stable key. + // <stable key> | <indexability discriminators> | <enableSlotBasedExecution boolean> + // This third part can be removed once the classic query engine reaches EOL and SBE is used + // exclusively for all query execution. Combined, the three parts make up the plan cache key. + // We store them in one std::string so that we can easily/cheaply extract the stable key. std::string _key; // How long the "stable key" is. diff --git a/src/mongo/db/query/plan_cache_test.cpp b/src/mongo/db/query/plan_cache_test.cpp index 07f98a84967..7780cc35c99 100644 --- a/src/mongo/db/query/plan_cache_test.cpp +++ b/src/mongo/db/query/plan_cache_test.cpp @@ -215,10 +215,11 @@ void assertPlanCacheKeysUnequalDueToDiscriminators(const PlanCacheKey& a, const } /** - * Check that the stable keys of 'a' and 'b' are equal, but the 'forceClassicEngine' values are not. + * Check that the stable keys of 'a' and 'b' are equal, but the 'enableSlotBasedExecutionEngine' + * values are not. */ -void assertPlanCacheKeysUnequalDueToForceClassicEngineValue(const PlanCacheKey& a, - const PlanCacheKey& b) { +void assertPlanCacheKeysUnequalDueToEnableSlotBasedExecutionEngineValue(const PlanCacheKey& a, + const PlanCacheKey& b) { ASSERT_EQ(a.getStableKeyStringData(), b.getStableKeyStringData()); auto aUnstablePart = a.getUnstablePart(); auto bUnstablePart = b.getUnstablePart(); @@ -1286,7 +1287,9 @@ protected: }; const std::string mockKey("mock_cache_key"); -const PlanCacheKey CachePlanSelectionTest::ck(mockKey, "", internalQueryForceClassicEngine.load()); +const PlanCacheKey CachePlanSelectionTest::ck(mockKey, + "", + internalQueryEnableSlotBasedExecutionEngine.load()); // // Equality @@ -2529,10 +2532,11 @@ TEST(PlanCacheTest, PlanCacheSizeWithMultiplePlanCaches) { } TEST(PlanCacheTest, DifferentQueryEngines) { - // Helper to construct a plan cache key given 'forceClassicEngine'. - auto constructPlanCacheKey = [](const PlanCache& pc, bool forceClassicEngine) -> PlanCacheKey { - RAIIServerParameterControllerForTest controller{"internalQueryForceClassicEngine", - forceClassicEngine}; + // Helper to construct a plan cache key given the 'enableSlotBasedExecutionEngine' flag. + auto constructPlanCacheKey = [](const PlanCache& pc, + bool enableSlotBasedExecutionEngine) -> PlanCacheKey { + RAIIServerParameterControllerForTest controller{ + "internalQueryEnableSlotBasedExecutionEngine", enableSlotBasedExecutionEngine}; const auto queryStr = "{a: 0}"; unique_ptr<CanonicalQuery> cq(canonicalize(queryStr)); return pc.computeKey(*cq); @@ -2548,11 +2552,12 @@ TEST(PlanCacheTest, DifferentQueryEngines) { false, // sparse IndexEntry::Identifier{""})}); // name - const auto classicEngineKey = constructPlanCacheKey(planCache, true); - const auto noClassicEngineKey = constructPlanCacheKey(planCache, false); + const auto classicEngineKey = constructPlanCacheKey(planCache, false); + const auto slotBasedExecutionEngineKey = constructPlanCacheKey(planCache, true); // Check that the two plan cache keys are not equal because the plans were created under // different engines. - assertPlanCacheKeysUnequalDueToForceClassicEngineValue(classicEngineKey, noClassicEngineKey); + assertPlanCacheKeysUnequalDueToEnableSlotBasedExecutionEngineValue(classicEngineKey, + slotBasedExecutionEngineKey); } } // namespace diff --git a/src/mongo/db/query/query_knobs.idl b/src/mongo/db/query/query_knobs.idl index ac6f992af65..fb43fd9c4c2 100644 --- a/src/mongo/db/query/query_knobs.idl +++ b/src/mongo/db/query/query_knobs.idl @@ -472,10 +472,11 @@ server_parameters: gt: 0 lte: { expr: BSONObjMaxInternalSize } - internalQueryForceClassicEngine: - description: "If true, force use of the classic query engine." + internalQueryEnableSlotBasedExecutionEngine: + description: "If true, the system will use the SBE execution engine for eligible queries, + otherwise all queries will execute using the classic execution engine." set_at: [ startup, runtime ] - cpp_varname: "internalQueryForceClassicEngine" + cpp_varname: "internalQueryEnableSlotBasedExecutionEngine" cpp_vartype: AtomicWord<bool> default: false diff --git a/src/mongo/dbtests/query_stage_multiplan.cpp b/src/mongo/dbtests/query_stage_multiplan.cpp index 0a89202af53..a0c2532aebd 100644 --- a/src/mongo/dbtests/query_stage_multiplan.cpp +++ b/src/mongo/dbtests/query_stage_multiplan.cpp @@ -547,7 +547,8 @@ TEST_F(QueryStageMultiPlanTest, MPSExplainAllPlans) { // // This is a regression test for SERVER-20111. TEST_F(QueryStageMultiPlanTest, MPSSummaryStats) { - RAIIServerParameterControllerForTest controller("internalQueryForceClassicEngine", true); + RAIIServerParameterControllerForTest controller("internalQueryEnableSlotBasedExecutionEngine", + false); const int N = 5000; for (int i = 0; i < N; ++i) { |