summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorEric Cox <eric.cox@mongodb.com>2021-09-23 01:23:46 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2021-09-23 01:46:02 +0000
commite76ba4e94882da7e1f9ab668a403eafde8516617 (patch)
tree40bbd158bf9211cd0b1dce57f01d2599d96ec546 /src
parentfc885a164c0595624d9b50b9d950880414777781 (diff)
downloadmongo-e76ba4e94882da7e1f9ab668a403eafde8516617.tar.gz
SERVER-60146 Check memory usage more frequently in HashAgg
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/exec/sbe/stages/hash_agg.cpp6
1 files changed, 5 insertions, 1 deletions
diff --git a/src/mongo/db/exec/sbe/stages/hash_agg.cpp b/src/mongo/db/exec/sbe/stages/hash_agg.cpp
index 5ae9c234c81..74c74e2b3a5 100644
--- a/src/mongo/db/exec/sbe/stages/hash_agg.cpp
+++ b/src/mongo/db/exec/sbe/stages/hash_agg.cpp
@@ -156,6 +156,9 @@ void HashAggStage::open(bool reOpen) {
_seekKeys.resize(_seekKeysAccessors.size());
+ // A counter to check memory usage periodically.
+ auto memoryUseCheckCounter = 0;
+
while (_children[0]->getNext() == PlanState::ADVANCED) {
value::MaterializedRow key{_inKeyAccessors.size()};
// Copy keys in order to do the lookup.
@@ -183,7 +186,8 @@ void HashAggStage::open(bool reOpen) {
// Track memory usage.
auto shouldCalculateEstimatedSize =
_pseudoRandom.nextCanonicalDouble() < _memoryUseSampleRate;
- if (shouldCalculateEstimatedSize) {
+ if (shouldCalculateEstimatedSize || ++memoryUseCheckCounter % 100 == 0) {
+ memoryUseCheckCounter = 0;
long estimatedSizeForOneRow =
it->first.memUsageForSorter() + it->second.memUsageForSorter();
long long estimatedTotalSize = _ht->size() * estimatedSizeForOneRow;