diff options
author | Yoonsoo Kim <yoonsoo.kim@mongodb.com> | 2022-11-23 18:26:36 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2022-11-23 19:39:03 +0000 |
commit | 836a5754997e1e63e42878088232ece2d7449ce8 (patch) | |
tree | 3e02113315836553b9d698091ec06470abfa90ee | |
parent | da178bf7277c25734fbed8f3d68c4206f65bb0ff (diff) | |
download | mongo-836a5754997e1e63e42878088232ece2d7449ce8.tar.gz |
SERVER-70493 Have SBE HashAgg report spill file size
-rw-r--r-- | jstests/aggregation/spill_to_disk.js | 2 | ||||
-rw-r--r-- | jstests/noPassthrough/spill_to_disk_secondary_read.js | 3 | ||||
-rw-r--r-- | src/mongo/db/exec/sbe/sbe_plan_stage_test.h | 3 | ||||
-rw-r--r-- | src/mongo/db/exec/sbe/stages/hash_agg.cpp | 4 | ||||
-rw-r--r-- | src/mongo/db/exec/sbe/stages/plan_stats.h | 1 |
5 files changed, 12 insertions, 1 deletions
diff --git a/jstests/aggregation/spill_to_disk.js b/jstests/aggregation/spill_to_disk.js index df33065ea1f..290df334e60 100644 --- a/jstests/aggregation/spill_to_disk.js +++ b/jstests/aggregation/spill_to_disk.js @@ -10,6 +10,7 @@ // @tags: [ // requires_collstats, // requires_pipeline_optimization, +// requires_persistence, // ] (function() { 'use strict'; @@ -64,6 +65,7 @@ function test({pipeline, expectedCodes, canSpillToDisk}) { assert(hashAggGroup.usedDisk, hashAggGroup); assert.gt(hashAggGroup.spilledRecords, 0, hashAggGroup); assert.gt(hashAggGroup.spilledBytesApprox, 0, hashAggGroup); + assert.gt(hashAggGroup.spilledRecordEstimatedStorageSize, 0, hashAggGroup); } } } else { diff --git a/jstests/noPassthrough/spill_to_disk_secondary_read.js b/jstests/noPassthrough/spill_to_disk_secondary_read.js index 057f4133265..217ce510eef 100644 --- a/jstests/noPassthrough/spill_to_disk_secondary_read.js +++ b/jstests/noPassthrough/spill_to_disk_secondary_read.js @@ -1,7 +1,7 @@ /* * Test that $group and $setWindowFields spill to the WT RecordStore on secondaries with * writeConcern greater than w:1. - * @tags: [requires_replication, requires_majority_read_concern] + * @tags: [requires_replication, requires_majority_read_concern, requires_persistence] */ (function() { "use strict"; @@ -92,6 +92,7 @@ const readColl = secondary.getDB("test").foo; assert(hashAggGroup.usedDisk, hashAggGroup); assert.eq(hashAggGroup.spilledRecords, expectedSpilledRecords, hashAggGroup); assert.gte(hashAggGroup.spilledBytesApprox, expectedSpilledBytesAtLeast, hashAggGroup); + assert.gt(hashAggGroup.spilledRecordEstimatedStorageSize, 0, hashAggGroup); } finally { assert.commandWorked(secondary.adminCommand({ setParameter: 1, diff --git a/src/mongo/db/exec/sbe/sbe_plan_stage_test.h b/src/mongo/db/exec/sbe/sbe_plan_stage_test.h index 36f9c8e85d7..5950e44b628 100644 --- a/src/mongo/db/exec/sbe/sbe_plan_stage_test.h +++ b/src/mongo/db/exec/sbe/sbe_plan_stage_test.h @@ -88,9 +88,11 @@ public: void setUp() override { CatalogTestFixture::setUp(); _slotIdGenerator.reset(new value::SlotIdGenerator()); + _globalLock.reset(new Lock::GlobalLock{operationContext(), MODE_IS}); } void tearDown() override { + _globalLock.reset(nullptr); _slotIdGenerator.reset(); CatalogTestFixture::tearDown(); } @@ -244,6 +246,7 @@ public: private: std::unique_ptr<value::SlotIdGenerator> _slotIdGenerator; + std::unique_ptr<Lock::GlobalLock> _globalLock{nullptr}; }; } // namespace mongo::sbe diff --git a/src/mongo/db/exec/sbe/stages/hash_agg.cpp b/src/mongo/db/exec/sbe/stages/hash_agg.cpp index b60052167d9..4061c99152d 100644 --- a/src/mongo/db/exec/sbe/stages/hash_agg.cpp +++ b/src/mongo/db/exec/sbe/stages/hash_agg.cpp @@ -496,6 +496,8 @@ PlanState HashAggStage::getNext() { return trackPlanState(PlanState::ADVANCED); } else { _rsCursor.reset(); + _specificStats.spilledRecordEstimatedStorageSize = + _recordStore->rs()->storageSize(_opCtx); _recordStore.reset(); return trackPlanState(PlanState::IS_EOF); } @@ -523,6 +525,8 @@ std::unique_ptr<PlanStageStats> HashAggStage::getStats(bool includeDebugInfo) co bob.appendNumber("spilledRecords", _specificStats.spilledRecords); bob.appendNumber("spilledBytesApprox", _specificStats.lastSpilledRecordSize * _specificStats.spilledRecords); + bob.appendNumber("spilledRecordEstimatedStorageSize", + _specificStats.spilledRecordEstimatedStorageSize); ret->debugInfo = bob.obj(); } diff --git a/src/mongo/db/exec/sbe/stages/plan_stats.h b/src/mongo/db/exec/sbe/stages/plan_stats.h index c84ae2c83e2..91d1be5b6ae 100644 --- a/src/mongo/db/exec/sbe/stages/plan_stats.h +++ b/src/mongo/db/exec/sbe/stages/plan_stats.h @@ -318,6 +318,7 @@ struct HashAggStats : public SpecificStats { bool usedDisk{false}; long long spilledRecords{0}; long long lastSpilledRecordSize{0}; + long long spilledRecordEstimatedStorageSize{0}; }; struct HashLookupStats : public SpecificStats { |