summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorauto-revert-processor <dev-prod-dag@mongodb.com>2022-10-21 01:19:01 +0000
committerEvergreen Agent <no-reply@evergreen.mongodb.com>2022-10-21 02:15:52 +0000
commitfab997bf60ede64f7e5ca78b15a9ad2661e88e6a (patch)
tree28f07cd8b1ec7d094bf65e3b38adce9f140fa025 /src
parent7bad8c9b694f599e49b4699f2dd149ebe210d188 (diff)
downloadmongo-fab997bf60ede64f7e5ca78b15a9ad2661e88e6a.tar.gz
Revert "SERVER-53657 Add 'spillFileSizeBytes' and 'numBytesSpilledEstimate' to $group execution stats explain output"
This reverts commit 7cda7dd4df551cb5ff95b0a913b6dbb812320def.
Diffstat (limited to 'src')
-rw-r--r--src/mongo/db/exec/plan_stats.h8
-rw-r--r--src/mongo/db/pipeline/document_source_group.cpp25
-rw-r--r--src/mongo/db/pipeline/document_source_group.h2
-rw-r--r--src/mongo/db/sorter/sorter_stats.cpp1
-rw-r--r--src/mongo/db/sorter/sorter_stats.h6
-rw-r--r--src/mongo/db/sorter/sorter_test.cpp1
6 files changed, 8 insertions, 35 deletions
diff --git a/src/mongo/db/exec/plan_stats.h b/src/mongo/db/exec/plan_stats.h
index 6ca25f01e69..8bf785a5b82 100644
--- a/src/mongo/db/exec/plan_stats.h
+++ b/src/mongo/db/exec/plan_stats.h
@@ -1040,14 +1040,6 @@ struct GroupStats : public SpecificStats {
// Tracks an estimate of the total size of all documents output by the group stage in bytes.
size_t totalOutputDataSizeBytes = 0;
- // The size of the file spilled to disk. Note that this is not the same as the number of bytes
- // spilled to disk, as any data spilled to disk will be compressed before being written to a
- // file.
- uint64_t spillFileSizeBytes = 0u;
-
- // The number of bytes evicted from memory and spilled to disk.
- uint64_t numBytesSpilledEstimate = 0u;
-
// The number of times that we spilled data to disk while grouping the data.
uint64_t spills = 0u;
};
diff --git a/src/mongo/db/pipeline/document_source_group.cpp b/src/mongo/db/pipeline/document_source_group.cpp
index 34164f9efc9..13694a79a60 100644
--- a/src/mongo/db/pipeline/document_source_group.cpp
+++ b/src/mongo/db/pipeline/document_source_group.cpp
@@ -152,6 +152,7 @@ bool DocumentSourceGroup::shouldSpillWithAttemptToSaveMemory() {
"Exceeded memory limit for $group, but didn't allow external sort."
" Pass allowDiskUse:true to opt in.",
_memoryTracker._allowDiskUse);
+ _memoryTracker.resetCurrent();
return true;
}
return false;
@@ -340,9 +341,6 @@ Value DocumentSourceGroup::serialize(boost::optional<ExplainOptions::Verbosity>
Value(static_cast<long long>(_stats.totalOutputDataSizeBytes));
out["usedDisk"] = Value(_stats.spills > 0);
out["spills"] = Value(static_cast<long long>(_stats.spills));
- out["spillFileSizeBytes"] = Value(static_cast<long long>(_stats.spillFileSizeBytes));
- out["numBytesSpilledEstimate"] =
- Value(static_cast<long long>(_stats.numBytesSpilledEstimate));
}
return Value(out.freezeToValue());
@@ -709,7 +707,6 @@ MONGO_COMPILER_NOINLINE DocumentSource::GetNextResult DocumentSourceGroup::initi
shared_ptr<Sorter<Value, Value>::Iterator> DocumentSourceGroup::spill() {
_stats.spills++;
- _stats.numBytesSpilledEstimate += _memoryTracker.currentMemoryBytes();
vector<const GroupsMap::value_type*> ptrs; // using pointers to speed sorting
ptrs.reserve(_groups->size());
@@ -721,12 +718,8 @@ shared_ptr<Sorter<Value, Value>::Iterator> DocumentSourceGroup::spill() {
// Initialize '_file' in a lazy manner only when it is needed.
if (!_file) {
- // Only track stats about spilling when running in execution level explain.
- if (pExpCtx->explain && *pExpCtx->explain >= ExplainOptions::Verbosity::kExecStats) {
- _spillStats = std::make_unique<SorterFileStats>(nullptr /* sorterTracker */);
- }
- _file = std::make_shared<Sorter<Value, Value>::File>(
- pExpCtx->tempDir + "/" + nextFileName(), _spillStats.get());
+ _file =
+ std::make_shared<Sorter<Value, Value>::File>(pExpCtx->tempDir + "/" + nextFileName());
}
SortedFileWriter<Value, Value> writer(SortOptions().TempDir(pExpCtx->tempDir), _file);
switch (_accumulatedFields.size()) { // same as ptrs[i]->second.size() for all i.
@@ -759,15 +752,13 @@ shared_ptr<Sorter<Value, Value>::Iterator> DocumentSourceGroup::spill() {
metricsCollector.incrementSorterSpills(1);
_groups->clear();
-
- // Zero out the current per-accumulation statement memory consumption, as well as the
- // current memory consumption, as the memory has been freed by spilling.
- _memoryTracker.resetCurrent();
+ // Zero out the current per-accumulation statement memory consumption, as the memory has been
+ // freed by spilling.
+ for (const auto& accum : _accumulatedFields) {
+ _memoryTracker.set(accum.fieldName, 0);
+ }
Sorter<Value, Value>::Iterator* iteratorPtr = writer.done();
- if (_spillStats) {
- _stats.spillFileSizeBytes = _spillStats->bytesSpilled();
- }
return shared_ptr<Sorter<Value, Value>::Iterator>(iteratorPtr);
}
diff --git a/src/mongo/db/pipeline/document_source_group.h b/src/mongo/db/pipeline/document_source_group.h
index 9588037c48f..2a3ac2ea89c 100644
--- a/src/mongo/db/pipeline/document_source_group.h
+++ b/src/mongo/db/pipeline/document_source_group.h
@@ -323,8 +323,6 @@ private:
// Only used when '_spilled' is true.
std::unique_ptr<Sorter<Value, Value>::Iterator> _sorterIterator;
- // Tracks the size of the spill file.
- std::unique_ptr<SorterFileStats> _spillStats = nullptr;
std::pair<Value, Value> _firstPartOfNextGroup;
bool _sbeCompatible;
diff --git a/src/mongo/db/sorter/sorter_stats.cpp b/src/mongo/db/sorter/sorter_stats.cpp
index 6b4a33b5864..ec68b02efcd 100644
--- a/src/mongo/db/sorter/sorter_stats.cpp
+++ b/src/mongo/db/sorter/sorter_stats.cpp
@@ -52,7 +52,6 @@ void SorterStats::setSpilledRanges(long long spills) {
SorterFileStats::SorterFileStats(SorterTracker* sorterTracker) : _sorterTracker(sorterTracker){};
void SorterFileStats::addSpilledDataSize(long long data) {
- _bytesSpilled += data;
if (_sorterTracker) {
_sorterTracker->bytesSpilled.fetchAndAdd(data);
}
diff --git a/src/mongo/db/sorter/sorter_stats.h b/src/mongo/db/sorter/sorter_stats.h
index a536333e27f..05bfa8998d4 100644
--- a/src/mongo/db/sorter/sorter_stats.h
+++ b/src/mongo/db/sorter/sorter_stats.h
@@ -48,14 +48,8 @@ public:
AtomicWord<long long> opened;
AtomicWord<long long> closed;
- long long bytesSpilled() const {
- return _bytesSpilled;
- }
-
private:
SorterTracker* _sorterTracker;
-
- long long _bytesSpilled = 0;
};
class SorterStats {
diff --git a/src/mongo/db/sorter/sorter_test.cpp b/src/mongo/db/sorter/sorter_test.cpp
index 89f69eeeb61..12e433217ef 100644
--- a/src/mongo/db/sorter/sorter_test.cpp
+++ b/src/mongo/db/sorter/sorter_test.cpp
@@ -351,7 +351,6 @@ public:
ASSERT_EQ(sorterFileStats.opened.load(), 2);
ASSERT_EQ(sorterFileStats.closed.load(), 2);
ASSERT_LTE(sorterTracker.bytesSpilled.load(), currentFileSize);
- ASSERT_LTE(sorterFileStats.bytesSpilled(), currentFileSize);
ASSERT(boost::filesystem::is_empty(tempDir.path()));
}