diff options
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/SConscript | 2 | ||||
-rw-r--r-- | src/mongo/db/catalog/SConscript | 2 | ||||
-rw-r--r-- | src/mongo/db/exec/plan_cache_util.cpp | 2 | ||||
-rw-r--r-- | src/mongo/db/exec/sbe/SConscript | 4 | ||||
-rw-r--r-- | src/mongo/db/exec/sbe/stages/plan_stats.h | 1 | ||||
-rw-r--r-- | src/mongo/db/query/SConscript | 50 | ||||
-rw-r--r-- | src/mongo/db/query/plan_cache_invalidator.cpp | 15 | ||||
-rw-r--r-- | src/mongo/db/query/plan_cache_invalidator.h | 20 | ||||
-rw-r--r-- | src/mongo/db/query/sbe_plan_cache.cpp | 15 |
9 files changed, 45 insertions, 66 deletions
diff --git a/src/mongo/db/SConscript b/src/mongo/db/SConscript index 06ce47556dd..fba19caaced 100644 --- a/src/mongo/db/SConscript +++ b/src/mongo/db/SConscript @@ -1297,7 +1297,6 @@ env.Library( 'query/sbe_cached_solution_planner.cpp', 'query/sbe_multi_planner.cpp', 'query/sbe_plan_ranker.cpp', - 'query/sbe_plan_cache.cpp', 'query/sbe_runtime_planner.cpp', 'query/sbe_stage_builder.cpp', 'query/sbe_stage_builder_accumulator.cpp', @@ -1349,6 +1348,7 @@ env.Library( 'pipeline/pipeline', 'query/plan_yield_policy', 'query/query_common', + 'query/query_plan_cache', 'query/query_planner', 'query/sbe_stage_builder_helpers', 'repl/repl_coordinator_interface', diff --git a/src/mongo/db/catalog/SConscript b/src/mongo/db/catalog/SConscript index d34320f8d82..1dfaf9476c9 100644 --- a/src/mongo/db/catalog/SConscript +++ b/src/mongo/db/catalog/SConscript @@ -504,11 +504,11 @@ env.Library( source=[ "$BUILD_DIR/mongo/db/query/collection_query_info.cpp", "$BUILD_DIR/mongo/db/query/collection_index_usage_tracker_decoration.cpp", - "$BUILD_DIR/mongo/db/query/plan_cache_invalidator.cpp", "$BUILD_DIR/mongo/db/query/plan_cache_key_factory.cpp", "$BUILD_DIR/mongo/db/query/query_settings_decoration.cpp", ], LIBDEPS=[ + '$BUILD_DIR/mongo/db/query/query_plan_cache', '$BUILD_DIR/mongo/db/query/query_planner', '$BUILD_DIR/mongo/db/update_index_data', ], diff --git a/src/mongo/db/exec/plan_cache_util.cpp b/src/mongo/db/exec/plan_cache_util.cpp index 0b40c431921..ef72a9d553b 100644 --- a/src/mongo/db/exec/plan_cache_util.cpp +++ b/src/mongo/db/exec/plan_cache_util.cpp @@ -32,8 +32,6 @@ #include "mongo/platform/basic.h" #include "mongo/db/exec/plan_cache_util.h" - -#include "mongo/db/query/explain.h" #include "mongo/logv2/log.h" namespace mongo::plan_cache_util { diff --git a/src/mongo/db/exec/sbe/SConscript b/src/mongo/db/exec/sbe/SConscript index e75bf78c705..dd83422caf7 100644 --- a/src/mongo/db/exec/sbe/SConscript +++ b/src/mongo/db/exec/sbe/SConscript @@ -65,9 +65,11 @@ sbeEnv.Library( '$BUILD_DIR/mongo/base', '$BUILD_DIR/mongo/db/exec/js_function', '$BUILD_DIR/mongo/db/exec/scoped_timer', + '$BUILD_DIR/mongo/db/mongohasher', '$BUILD_DIR/mongo/db/query/plan_yield_policy', - '$BUILD_DIR/mongo/db/query/query_planner', + '$BUILD_DIR/mongo/db/query/query_index_bounds', '$BUILD_DIR/mongo/db/service_context', + '$BUILD_DIR/mongo/db/stats/resource_consumption_metrics', '$BUILD_DIR/mongo/db/storage/encryption_hooks', '$BUILD_DIR/mongo/db/storage/index_entry_comparison', '$BUILD_DIR/mongo/util/concurrency/thread_pool', diff --git a/src/mongo/db/exec/sbe/stages/plan_stats.h b/src/mongo/db/exec/sbe/stages/plan_stats.h index 50bff42fd2a..9e77c76ad5f 100644 --- a/src/mongo/db/exec/sbe/stages/plan_stats.h +++ b/src/mongo/db/exec/sbe/stages/plan_stats.h @@ -31,7 +31,6 @@ #include "mongo/db/exec/plan_stats.h" #include "mongo/db/exec/plan_stats_visitor.h" -#include "mongo/db/query/stage_types.h" namespace mongo::sbe { struct CommonStats { diff --git a/src/mongo/db/query/SConscript b/src/mongo/db/query/SConscript index 352bf2a7181..cf1cfea8d5f 100644 --- a/src/mongo/db/query/SConscript +++ b/src/mongo/db/query/SConscript @@ -33,18 +33,11 @@ env.Library( ) env.Library( - target='query_planner', + target="query_planner", source=[ - "classic_plan_cache.cpp", "expression_index_knobs.idl", "expression_index.cpp", "index_bounds_builder.cpp", - "index_bounds.cpp", - "index_entry.cpp", - "index_tag.cpp", - "interval.cpp", - "plan_cache_callbacks.cpp", - "plan_cache_debug_info.cpp", "plan_cache_indexability.cpp", "plan_enumerator.cpp", "planner_access.cpp", @@ -59,18 +52,16 @@ env.Library( ], LIBDEPS=[ "$BUILD_DIR/mongo/base", - "$BUILD_DIR/mongo/db/bson/dotted_path_support", "$BUILD_DIR/mongo/db/catalog/clustered_collection_options", - '$BUILD_DIR/mongo/db/commands/server_status_core', - "$BUILD_DIR/mongo/db/exec/projection_executor", + "$BUILD_DIR/mongo/db/commands/server_status_core", "$BUILD_DIR/mongo/db/exec/sbe/query_sbe_plan_stats", "$BUILD_DIR/mongo/db/index/expression_params", "$BUILD_DIR/mongo/db/index/key_generator", "$BUILD_DIR/mongo/db/index_names", - "$BUILD_DIR/mongo/db/mongohasher", - 'canonical_query', - "command_request_response", + "canonical_query", + "query_index_bounds", "query_knobs", + "query_plan_cache", ], LIBDEPS_PRIVATE=[ '$BUILD_DIR/mongo/db/fts/base_fts', @@ -80,6 +71,36 @@ env.Library( ) env.Library( + target="query_index_bounds", + source=[ + "index_bounds.cpp", + "index_entry.cpp", + "index_tag.cpp", + "interval.cpp", + ], + LIBDEPS=[ + "$BUILD_DIR/mongo/base", + "$BUILD_DIR/mongo/db/matcher/expressions", + ] +) + +env.Library( + target="query_plan_cache", + source=[ + "classic_plan_cache.cpp", + "plan_cache_callbacks.cpp", + "plan_cache_debug_info.cpp", + "plan_cache_invalidator.cpp", + "sbe_plan_cache.cpp", + ], + LIBDEPS=[ + "$BUILD_DIR/mongo/base", + "$BUILD_DIR/mongo/db/exec/sbe/query_sbe", + "canonical_query", + ] +) + +env.Library( target='sbe_stage_builder_helpers', source=[ "sbe_stage_builder_helpers.cpp", @@ -387,7 +408,6 @@ env.CppUnitTest( "$BUILD_DIR/mongo/util/clock_source_mock", "collation/collator_factory_mock", "collation/collator_interface_mock", - "command_request_response", "common_query_enums_and_helpers", "hint_parser", "map_reduce_output_format", diff --git a/src/mongo/db/query/plan_cache_invalidator.cpp b/src/mongo/db/query/plan_cache_invalidator.cpp index 7e673379e99..e315ea7f78c 100644 --- a/src/mongo/db/query/plan_cache_invalidator.cpp +++ b/src/mongo/db/query/plan_cache_invalidator.cpp @@ -31,6 +31,7 @@ #include "mongo/db/query/plan_cache_invalidator.h" +#include "mongo/db/query/sbe_plan_cache.h" #include "mongo/logv2/log.h" namespace mongo { @@ -38,21 +39,13 @@ namespace { const auto getCollectionVersionNumber = SharedCollectionDecorations::declareDecoration<AtomicWord<size_t>>(); - -const auto getCallback = - ServiceContext::declareDecoration<std::unique_ptr<PlanCacheInvalidatorCallback>>(); } // namespace -void PlanCacheInvalidatorCallback::set(ServiceContext* serviceContext, - std::unique_ptr<PlanCacheInvalidatorCallback> callback) { - getCallback(serviceContext) = std::move(callback); -} - PlanCacheInvalidator::PlanCacheInvalidator(const CollectionPtr& collection, ServiceContext* serviceContext) : _version{getCollectionVersionNumber(collection->getSharedDecorations()).fetchAndAdd(1u)}, _uuid{collection->uuid()}, - _callback{getCallback(serviceContext).get()} {} + _serviceContext{serviceContext} {} PlanCacheInvalidator::~PlanCacheInvalidator() { try { @@ -70,8 +63,8 @@ PlanCacheInvalidator::~PlanCacheInvalidator() { void PlanCacheInvalidator::clearPlanCache() const { // Some unit tests cannot properly initialize CollectionQueryInfo but rely on it partially // initialized to make PlanCacheKeys. - if (_callback && _uuid) { - _callback->invalidateCacheEntriesWith(*_uuid, _version); + if (_serviceContext && _uuid) { + sbe::clearPlanCacheEntriesWith(_serviceContext, *_uuid, _version); } } diff --git a/src/mongo/db/query/plan_cache_invalidator.h b/src/mongo/db/query/plan_cache_invalidator.h index 62beae0e494..f36abf63cc5 100644 --- a/src/mongo/db/query/plan_cache_invalidator.h +++ b/src/mongo/db/query/plan_cache_invalidator.h @@ -32,23 +32,6 @@ #include "mongo/db/catalog/collection.h" namespace mongo { - -/** - * Encapsulates a callback function called on the SBE Plan Cache invalidation. - */ -class PlanCacheInvalidatorCallback { -public: - /** - * Stores the callback as a service context decoration. - */ - static void set(ServiceContext* serviceContext, - std::unique_ptr<PlanCacheInvalidatorCallback> callback); - - virtual ~PlanCacheInvalidatorCallback() = default; - - virtual void invalidateCacheEntriesWith(UUID collectionUuid, size_t oldVersion) = 0; -}; - /** * Controls life-time of PlanCache entries associated with a particular collection of a particular * version. A new copy of the collection is created each time the collection @@ -81,7 +64,6 @@ private: // The collection's UUID. const boost::optional<UUID> _uuid{}; - // A callback to be called when we need to clean PlanCache. - PlanCacheInvalidatorCallback* const _callback{}; + ServiceContext* const _serviceContext{}; }; } // namespace mongo diff --git a/src/mongo/db/query/sbe_plan_cache.cpp b/src/mongo/db/query/sbe_plan_cache.cpp index 0c5edf92199..28f97cd886d 100644 --- a/src/mongo/db/query/sbe_plan_cache.cpp +++ b/src/mongo/db/query/sbe_plan_cache.cpp @@ -31,7 +31,6 @@ #include "mongo/db/query/sbe_plan_cache.h" -#include "mongo/db/query/plan_cache_invalidator.h" #include "mongo/db/query/plan_cache_size_parameter.h" #include "mongo/db/server_options.h" #include "mongo/logv2/log.h" @@ -43,18 +42,6 @@ namespace { const auto sbePlanCacheDecoration = ServiceContext::declareDecoration<std::unique_ptr<sbe::PlanCache>>(); -class SbePlanCacheInvalidatorCallback final : public PlanCacheInvalidatorCallback { -public: - SbePlanCacheInvalidatorCallback(ServiceContext* serviceCtx) : _serviceCtx{serviceCtx} {} - - void invalidateCacheEntriesWith(UUID collectionUuid, size_t oldVersion) override { - clearPlanCacheEntriesWith(_serviceCtx, collectionUuid, oldVersion); - } - -private: - ServiceContext* _serviceCtx; -}; - size_t convertToSizeInBytes(const plan_cache_util::PlanCacheSizeParameter& param) { constexpr size_t kBytesInMB = 1014 * 1024; constexpr size_t kMBytesInGB = 1014; @@ -129,8 +116,6 @@ ServiceContext::ConstructorActionRegisterer planCacheRegisterer{ plan_cache_util::sbePlanCacheSizeUpdaterDecoration(serviceCtx) = std::make_unique<PlanCacheSizeUpdaterImpl>(); - PlanCacheInvalidatorCallback::set( - serviceCtx, std::make_unique<SbePlanCacheInvalidatorCallback>(serviceCtx)); if (feature_flags::gFeatureFlagSbePlanCache.isEnabledAndIgnoreFCV()) { auto status = plan_cache_util::PlanCacheSizeParameter::parse(planCacheSize.get()); uassertStatusOK(status); |