diff options
author | Henrik Edin <henrik.edin@mongodb.com> | 2020-04-06 16:05:10 -0400 |
---|---|---|
committer | Evergreen Agent <no-reply@evergreen.mongodb.com> | 2020-04-10 15:02:47 +0000 |
commit | da923cf72003a34a45ce7775dd66ccd944da7d11 (patch) | |
tree | 64278565411e93bdb0835e67e41f35a8997ab316 /src/mongo/db/storage/key_string_test.cpp | |
parent | 3d929ed533a72446353b18b5d60770aed33b58f1 (diff) | |
download | mongo-da923cf72003a34a45ce7775dd66ccd944da7d11.tar.gz |
SERVER-47001 Added a pooled KeyString builder.
It uses a memory pool in the execution context to be able to share a
larger memory buffer for multiple KeyStrings.
Added SharedBufferFragment and SharedBufferFragmentBuilder to achieve this.
Diffstat (limited to 'src/mongo/db/storage/key_string_test.cpp')
-rw-r--r-- | src/mongo/db/storage/key_string_test.cpp | 26 |
1 files changed, 20 insertions, 6 deletions
diff --git a/src/mongo/db/storage/key_string_test.cpp b/src/mongo/db/storage/key_string_test.cpp index 5cab3e5a450..c89603648a3 100644 --- a/src/mongo/db/storage/key_string_test.cpp +++ b/src/mongo/db/storage/key_string_test.cpp @@ -740,18 +740,32 @@ TEST_F(KeyStringBuilderTest, ReasonableSize) { KeyString::Version::kLatestVersion, BSONObj(), ALL_ASCENDING); ASSERT_LTE(sizeof(heapBuilder), 96); + // Use large 1KB blocks and verify that we use way less + SharedBufferFragmentBuilder fragmentBuilder(1024); + KeyString::PooledBuilder pooledBuilder( + fragmentBuilder, KeyString::Version::kLatestVersion, BSONObj(), ALL_ASCENDING); + ASSERT_LTE(sizeof(pooledBuilder), 96); + // Test the dynamic memory usage reported to the sorter. KeyString::Value value1 = stackBuilder.getValueCopy(); - ASSERT_LTE(sizeof(value1), 24); - ASSERT_LTE(value1.memUsageForSorter(), 26); + ASSERT_LTE(sizeof(value1), 32); + ASSERT_LTE(value1.memUsageForSorter(), 34); KeyString::Value value2 = heapBuilder.getValueCopy(); - ASSERT_LTE(sizeof(value2), 24); - ASSERT_LTE(value2.memUsageForSorter(), 26); + ASSERT_LTE(sizeof(value2), 32); + ASSERT_LTE(value2.memUsageForSorter(), 34); KeyString::Value value3 = heapBuilder.release(); - ASSERT_LTE(sizeof(value3), 24); - ASSERT_LTE(value3.memUsageForSorter(), 56); + ASSERT_LTE(sizeof(value3), 32); + ASSERT_LTE(value3.memUsageForSorter(), 64); + + KeyString::Value value4 = pooledBuilder.getValueCopy(); + ASSERT_LTE(sizeof(value4), 32); + ASSERT_LTE(value4.memUsageForSorter(), 34); + + KeyString::Value value5 = pooledBuilder.release(); + ASSERT_LTE(sizeof(value5), 32); + ASSERT_LTE(value5.memUsageForSorter(), 34); } TEST_F(KeyStringBuilderTest, LotsOfNumbers1) { |