diff options
author | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-09 14:10:14 +0000 |
---|---|---|
committer | Henning Baldersheim <balder@yahoo-inc.com> | 2023-03-09 14:10:58 +0000 |
commit | 414f81bdd8fa59944f79d86b9ca7c03d1e4080f4 (patch) | |
tree | df92895f93a0446ff6ed1ee410af434916e5e449 /vespalib/src/tests | |
parent | 435af93308d985ec4c503d3789a6d48f923dd60a (diff) |
Report more of the static memory usage for datastores.
Diffstat (limited to 'vespalib/src/tests')
4 files changed, 31 insertions, 21 deletions
diff --git a/vespalib/src/tests/btree/btree_test.cpp b/vespalib/src/tests/btree/btree_test.cpp index 2a465f2c60a..ef64549e16a 100644 --- a/vespalib/src/tests/btree/btree_test.cpp +++ b/vespalib/src/tests/btree/btree_test.cpp @@ -1064,6 +1064,7 @@ adjustAllocatedBytes(size_t nodeCount, size_t nodeSize) TEST_F(BTreeTest, require_that_memory_usage_is_calculated) { + constexpr size_t BASE = 163912; typedef BTreeNodeAllocator<int32_t, int8_t, btree::NoAggregated, MyTraits::INTERNAL_SLOTS, MyTraits::LEAF_SLOTS> NodeAllocator; @@ -1082,6 +1083,8 @@ TEST_F(BTreeTest, require_that_memory_usage_is_calculated) const uint32_t initialLeafNodes = 128u; mu.incAllocatedBytes(adjustAllocatedBytes(initialInternalNodes, sizeof(INode))); mu.incAllocatedBytes(adjustAllocatedBytes(initialLeafNodes, sizeof(LNode))); + mu.incAllocatedBytes(BASE); + mu.incUsedBytes(BASE); mu.incUsedBytes(sizeof(INode)); mu.incDeadBytes(sizeof(INode)); EXPECT_TRUE(assertMemoryUsage(mu, tm.getMemoryUsage())); @@ -1112,6 +1115,8 @@ TEST_F(BTreeTest, require_that_memory_usage_is_calculated) mu = vespalib::MemoryUsage(); mu.incAllocatedBytes(adjustAllocatedBytes(initialInternalNodes, sizeof(INode))); mu.incAllocatedBytes(adjustAllocatedBytes(initialLeafNodes, sizeof(LNode))); + mu.incAllocatedBytes(BASE); + mu.incUsedBytes(BASE); mu.incUsedBytes(sizeof(INode) * 2); mu.incDeadBytes(sizeof(INode) * 2); mu.incUsedBytes(sizeof(LNode)); diff --git a/vespalib/src/tests/datastore/array_store/array_store_test.cpp b/vespalib/src/tests/datastore/array_store/array_store_test.cpp index 063ac445933..3ebe8fdba1a 100644 --- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp +++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp @@ -218,8 +218,8 @@ TEST_P(NumberStoreTest, control_static_sizes) { #endif EXPECT_EQ(112u, sizeof(NumberStoreTest::ArrayStoreType::SmallBufferType)); MemoryUsage usage = store.getMemoryUsage(); - EXPECT_EQ(960u, usage.allocatedBytes()); - EXPECT_EQ(32u, usage.usedBytes()); + EXPECT_EQ(1312160u, usage.allocatedBytes()); + EXPECT_EQ(1311232u, usage.usedBytes()); } TEST_P(NumberStoreTest, add_and_get_small_arrays_of_trivial_type) diff --git a/vespalib/src/tests/datastore/datastore/datastore_test.cpp b/vespalib/src/tests/datastore/datastore/datastore_test.cpp index bffd32816a4..794be39ae9b 100644 --- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp +++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp @@ -474,6 +474,7 @@ TEST(DataStoreTest, require_that_memory_stats_are_calculated) TEST(DataStoreTest, require_that_memory_usage_is_calculated) { + constexpr size_t BASE = 676; MyStore s; MyRef r = s.addEntry(10); s.addEntry(20); @@ -482,8 +483,8 @@ TEST(DataStoreTest, require_that_memory_usage_is_calculated) s.holdBuffer(r.bufferId()); s.assign_generation(100); vespalib::MemoryUsage m = s.getMemoryUsage(); - EXPECT_EQ(MyRef::offsetSize() * sizeof(int), m.allocatedBytes()); - EXPECT_EQ(5 * sizeof(int), m.usedBytes()); + EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE, m.allocatedBytes()); + EXPECT_EQ(5 * sizeof(int) + BASE, m.usedBytes()); EXPECT_EQ(0 * sizeof(int), m.deadBytes()); EXPECT_EQ(5 * sizeof(int), m.allocatedBytesOnHold()); s.reclaim_memory(101); @@ -491,27 +492,28 @@ TEST(DataStoreTest, require_that_memory_usage_is_calculated) TEST(DataStoreTest, require_that_we_can_disable_elemement_hold_list) { + constexpr size_t BASE = 676; MyStore s; MyRef r1 = s.addEntry(10); MyRef r2 = s.addEntry(20); MyRef r3 = s.addEntry(30); (void) r3; vespalib::MemoryUsage m = s.getMemoryUsage(); - EXPECT_EQ(MyRef::offsetSize() * sizeof(int), m.allocatedBytes()); - EXPECT_EQ(4 * sizeof(int), m.usedBytes()); + EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE, m.allocatedBytes()); + EXPECT_EQ(4 * sizeof(int) + BASE, m.usedBytes()); EXPECT_EQ(1 * sizeof(int), m.deadBytes()); EXPECT_EQ(0 * sizeof(int), m.allocatedBytesOnHold()); s.holdElem(r1, 1); m = s.getMemoryUsage(); - EXPECT_EQ(MyRef::offsetSize() * sizeof(int), m.allocatedBytes()); - EXPECT_EQ(4 * sizeof(int), m.usedBytes()); + EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE, m.allocatedBytes()); + EXPECT_EQ(4 * sizeof(int) + BASE, m.usedBytes()); EXPECT_EQ(1 * sizeof(int), m.deadBytes()); EXPECT_EQ(1 * sizeof(int), m.allocatedBytesOnHold()); s.disableElemHoldList(); s.holdElem(r2, 1); m = s.getMemoryUsage(); - EXPECT_EQ(MyRef::offsetSize() * sizeof(int), m.allocatedBytes()); - EXPECT_EQ(4 * sizeof(int), m.usedBytes()); + EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE, m.allocatedBytes()); + EXPECT_EQ(4 * sizeof(int) + BASE, m.usedBytes()); EXPECT_EQ(2 * sizeof(int), m.deadBytes()); EXPECT_EQ(1 * sizeof(int), m.allocatedBytesOnHold()); s.assign_generation(100); @@ -536,30 +538,31 @@ void assertGrowStats(GrowthStats expSizes, TEST(DataStoreTest, require_that_buffer_growth_works) { + constexpr size_t BASE = 41032u; // Always switch to new buffer, min size 4 assertGrowStats({ 4, 4, 4, 4, 8, 16, 16, 32, 64, 64 }, - { 4 }, 20, 4, 0); + { 4 }, 20 + BASE, 4, 0); // Resize if buffer size is less than 4, min size 0 assertGrowStats({ 4, 4, 8, 32, 32, 64, 64, 128, 128, 128 }, - { 0, 1, 2, 4 }, 4, 0, 4); + { 0, 1, 2, 4 }, 4 + BASE, 0, 4); // Always switch to new buffer, min size 16 assertGrowStats({ 16, 16, 16, 32, 32, 64, 128, 128, 128 }, - { 16 }, 68, 16, 0); + { 16 }, 68 + BASE, 16, 0); // Resize if buffer size is less than 16, min size 0 assertGrowStats({ 16, 32, 32, 128, 128, 128, 128, 128, 128 }, - { 0, 1, 2, 4, 8, 16 }, 4, 0, 16); + { 0, 1, 2, 4, 8, 16 }, 4 + BASE, 0, 16); // Resize if buffer size is less than 16, min size 4 assertGrowStats({ 16, 32, 32, 128, 128, 128, 128, 128, 128 }, - { 4, 8, 16 }, 20, 4, 16); + { 4, 8, 16 }, 20 + BASE, 4, 16); // Always switch to new buffer, min size 0 assertGrowStats({ 1, 1, 1, 1, 1, 2, 2, 4, 8, 8, 16, 32 }, - { 0, 1 }, 4, 0, 0); + { 0, 1 }, 4 + BASE, 0, 0); // Buffers with sizes larger than the huge page size of the mmap allocator. ASSERT_EQ(524288u, HUGE_PAGE_ARRAY_SIZE); assertGrowStats({ 262144, 524288, 524288, 524288 * 3, 524288 * 3, 524288 * 5, 524288 * 5, 524288 * 5, 524288 * 5, 524288 * 5 }, { 0, 1, 2, 4, 8, 16, 32, 64, 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 32768, 65536, 131072, 262144 }, - 4, 0, HUGE_PAGE_ARRAY_SIZE / 2, HUGE_PAGE_ARRAY_SIZE * 5); + 4 + BASE, 0, HUGE_PAGE_ARRAY_SIZE / 2, HUGE_PAGE_ARRAY_SIZE * 5); } using RefType15 = EntryRefT<15>; // offsetSize=32768 diff --git a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp index 40920a8ca1b..cf62d238d53 100644 --- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp +++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp @@ -472,10 +472,12 @@ TEST_F(DoubleTest, nan_is_handled) TEST_F(DoubleTest, control_memory_usage) { EXPECT_EQ(464, sizeof(store)); EXPECT_EQ(144u, sizeof(BufferState)); - EXPECT_EQ(32u, store.get_values_memory_usage().allocatedBytes()); - EXPECT_EQ(98208u, store.get_dictionary_memory_usage().allocatedBytes()); - EXPECT_EQ(98240u, store.getMemoryUsage().allocatedBytes()); - EXPECT_EQ(280u, store.getMemoryUsage().usedBytes()); + EXPECT_EQ(163908u, store.get_values_memory_usage().allocatedBytes()); + EXPECT_EQ(163892u, store.get_values_memory_usage().usedBytes()); + EXPECT_EQ(262120u, store.get_dictionary_memory_usage().allocatedBytes()); + EXPECT_EQ(164176u, store.get_dictionary_memory_usage().usedBytes()); + EXPECT_EQ(426028u, store.getMemoryUsage().allocatedBytes()); + EXPECT_EQ(328068u, store.getMemoryUsage().usedBytes()); } GTEST_MAIN_RUN_ALL_TESTS() |