diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2021-11-01 20:27:51 +0000 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2021-11-01 21:22:52 +0000 |
commit | 5d1078c60e8f24e027dc72d7ceeac4dab49908b9 (patch) | |
tree | 0d81f98332343167a56a7c350f1f3deb8c6da2a7 /src/mongo/dbtests | |
parent | 8ac4553c3d5c7509ea708c31a7f0232b2b3d4f4f (diff) | |
download | mongo-5d1078c60e8f24e027dc72d7ceeac4dab49908b9.tar.gz |
SERVER-61094 Use a dedicated pooled KeyString builder per index
This avoids underlying SharedBuffer to be shared for KeyString for
separate indexes. Allows indexes that need to spill to disk to
independently free memory instead of being pinned by unrelated other
indexes.
Diffstat (limited to 'src/mongo/dbtests')
-rw-r--r-- | src/mongo/dbtests/validate_tests.cpp | 62 |
1 files changed, 34 insertions, 28 deletions
diff --git a/src/mongo/dbtests/validate_tests.cpp b/src/mongo/dbtests/validate_tests.cpp index 60f4fd089c0..859348bd8d2 100644 --- a/src/mongo/dbtests/validate_tests.cpp +++ b/src/mongo/dbtests/validate_tests.cpp @@ -809,7 +809,8 @@ public: return; } - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection, insert three records and check it's valid. lockDb(MODE_X); @@ -863,7 +864,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -875,8 +876,8 @@ public: auto removeStatus = iam->removeKeys(&_opCtx, {keys.begin(), keys.end()}, id1, options, &numDeleted); - auto insertStatus = - iam->insert(&_opCtx, coll, badKey, id1, options, nullptr, &numInserted); + auto insertStatus = iam->insert( + &_opCtx, pooledBuilder, coll, badKey, id1, options, nullptr, &numInserted); ASSERT_EQUALS(numDeleted, 1); ASSERT_EQUALS(numInserted, 1); @@ -1207,7 +1208,8 @@ public: return; } - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -1267,7 +1269,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -1591,7 +1593,8 @@ public: ValidateMissingIndexEntryRepair() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -1651,7 +1654,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -1926,7 +1929,8 @@ public: : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert a document. lockDb(MODE_X); @@ -1998,7 +2002,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, dupObj, IndexAccessMethod::GetKeysMode::kRelaxConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -2049,7 +2053,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2140,8 +2144,8 @@ public: : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert non-multikey document. lockDb(MODE_X); @@ -2188,7 +2192,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, doc, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2321,7 +2325,8 @@ public: ValidateDuplicateDocumentIndexKeySet() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -2393,7 +2398,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2432,7 +2437,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, actualKey, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2469,7 +2474,8 @@ public: return; } - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection. lockDb(MODE_X); @@ -2547,7 +2553,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, dupObj, IndexAccessMethod::GetKeysMode::kRelaxConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -2594,7 +2600,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, dupObj, IndexAccessMethod::GetKeysMode::kRelaxConstraints, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -2892,8 +2898,8 @@ public: ValidateIndexWithMultikeyDocRepair() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert non-multikey document. lockDb(MODE_X); @@ -2940,7 +2946,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, doc, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -2976,7 +2982,7 @@ public: MultikeyPaths multikeyPaths; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, mkDoc, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kAddingKeys, @@ -3118,8 +3124,8 @@ public: ValidateMultikeyPathCoverageRepair() : ValidateBase(/*full=*/false, /*background=*/false) {} void run() { - - auto& executionCtx = StorageExecutionContext::get(&_opCtx); + SharedBufferFragmentBuilder pooledBuilder( + KeyString::HeapBuilder::kHeapAllocatorDefaultBytes); // Create a new collection and insert multikey document. lockDb(MODE_X); @@ -3169,7 +3175,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, doc1, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kRemovingKeys, @@ -3206,7 +3212,7 @@ public: KeyStringSet keys; iam->getKeys(&_opCtx, coll, - executionCtx.pooledBufferBuilder(), + pooledBuilder, doc2, IndexAccessMethod::GetKeysMode::kRelaxConstraintsUnfiltered, IndexAccessMethod::GetKeysContext::kAddingKeys, |