diff options
author | David Storch <david.storch@mongodb.com> | 2023-02-01 18:04:44 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2023-02-21 22:03:41 +0000 |
commit | 94885f0f19862250726fa297664c547820240329 (patch) | |
tree | 6cea543175b907ba4b6783d89e727dbba26c238c /src | |
parent | 5a85ba8e15a9f0968c2307e35aefc8c259bc7151 (diff) | |
download | mongo-94885f0f19862250726fa297664c547820240329.tar.gz |
SERVER-71680 Fix SBE HashAggStage to update $operationMetrics when spilling
(cherry picked from commit de878b253df6ba63773e52e9ba21c70a72683bff)
Diffstat (limited to 'src')
-rw-r--r-- | src/mongo/db/exec/sbe/stages/hash_agg.cpp | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/src/mongo/db/exec/sbe/stages/hash_agg.cpp b/src/mongo/db/exec/sbe/stages/hash_agg.cpp index f5e67981bcc..bdbcda14805 100644 --- a/src/mongo/db/exec/sbe/stages/hash_agg.cpp +++ b/src/mongo/db/exec/sbe/stages/hash_agg.cpp @@ -27,17 +27,16 @@ * it in the license file. */ -#include "mongo/platform/basic.h" +#include "mongo/db/exec/sbe/stages/hash_agg.h" #include "mongo/db/concurrency/d_concurrency.h" -#include "mongo/db/exec/sbe/stages/hash_agg.h" +#include "mongo/db/exec/sbe/size_estimator.h" #include "mongo/db/exec/sbe/util/spilling.h" +#include "mongo/db/stats/resource_consumption_metrics.h" #include "mongo/db/storage/kv/kv_engine.h" #include "mongo/db/storage/storage_engine.h" #include "mongo/util/str.h" -#include "mongo/db/exec/sbe/size_estimator.h" - namespace mongo { namespace sbe { HashAggStage::HashAggStage(std::unique_ptr<PlanStage> input, @@ -301,6 +300,15 @@ void HashAggStage::spill(MemoryCheckData& mcd) { for (auto&& it : *_ht) { spillRowToDisk(it.first, it.second); } + + auto& metricsCollector = ResourceConsumption::MetricsCollector::get(_opCtx); + // We're not actually doing any sorting here or using the 'Sorter' class, but for the purposes + // of $operationMetrics we incorporate the number of spilled records into the "keysSorted" + // metric. Similarly, "sorterSpills" despite the name counts the number of individual spill + // events. + metricsCollector.incrementKeysSorted(_ht->size()); + metricsCollector.incrementSorterSpills(1); + _ht->clear(); ++_specificStats.numSpills; |