aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/datastore
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-11 14:51:34 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-13 12:50:29 +0000
commit8ad3f6f9fc210ced8915275f795c660fe87ef4a4 (patch)
tree4cbe2e9df5bf9eef21dba06b082fcce1486285b3 /vespalib/src/tests/datastore
parente73005677cdbc12d1cb613e3020b4fa0dbaef268 (diff)
Allocate BufferState in stash and add pointer to BufferAndMeta
Diffstat (limited to 'vespalib/src/tests/datastore')
-rw-r--r--vespalib/src/tests/datastore/array_store/array_store_test.cpp12
-rw-r--r--vespalib/src/tests/datastore/datastore/datastore_test.cpp24
-rw-r--r--vespalib/src/tests/datastore/unique_store/unique_store_test.cpp14
3 files changed, 26 insertions, 24 deletions
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 97e1ddb985d..c32554232ef 100644
--- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp
+++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp
@@ -210,16 +210,16 @@ INSTANTIATE_TEST_SUITE_P(NumberStoreFreeListsDisabledMultiTest,
TEST_P(NumberStoreTest, control_static_sizes) {
#ifdef _LIBCPP_VERSION
- EXPECT_EQ(472u, sizeof(store));
- EXPECT_EQ(296u, sizeof(NumberStoreTest::ArrayStoreType::DataStoreType));
+ EXPECT_EQ(464u, sizeof(store));
+ EXPECT_EQ(280u, sizeof(NumberStoreTest::ArrayStoreType::DataStoreType));
#else
- EXPECT_EQ(504u, sizeof(store));
- EXPECT_EQ(328u, sizeof(NumberStoreTest::ArrayStoreType::DataStoreType));
+ EXPECT_EQ(496u, sizeof(store));
+ EXPECT_EQ(320u, sizeof(NumberStoreTest::ArrayStoreType::DataStoreType));
#endif
EXPECT_EQ(112u, sizeof(NumberStoreTest::ArrayStoreType::SmallBufferType));
MemoryUsage usage = store.getMemoryUsage();
- EXPECT_EQ(1312160u, usage.allocatedBytes());
- EXPECT_EQ(1311232u, usage.usedBytes());
+ EXPECT_EQ(202144u, usage.allocatedBytes());
+ EXPECT_EQ(197776u, 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 794be39ae9b..7121bf5ce11 100644
--- a/vespalib/src/tests/datastore/datastore/datastore_test.cpp
+++ b/vespalib/src/tests/datastore/datastore/datastore_test.cpp
@@ -474,7 +474,8 @@ TEST(DataStoreTest, require_that_memory_stats_are_calculated)
TEST(DataStoreTest, require_that_memory_usage_is_calculated)
{
- constexpr size_t BASE = 676;
+ constexpr size_t BASE_ALLOCATED = 4228;
+ constexpr size_t BASE_USED = 308;
MyStore s;
MyRef r = s.addEntry(10);
s.addEntry(20);
@@ -483,8 +484,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) + BASE, m.allocatedBytes());
- EXPECT_EQ(5 * sizeof(int) + BASE, m.usedBytes());
+ EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE_ALLOCATED, m.allocatedBytes());
+ EXPECT_EQ(5 * sizeof(int) + BASE_USED, m.usedBytes());
EXPECT_EQ(0 * sizeof(int), m.deadBytes());
EXPECT_EQ(5 * sizeof(int), m.allocatedBytesOnHold());
s.reclaim_memory(101);
@@ -492,28 +493,29 @@ TEST(DataStoreTest, require_that_memory_usage_is_calculated)
TEST(DataStoreTest, require_that_we_can_disable_elemement_hold_list)
{
- constexpr size_t BASE = 676;
+ constexpr size_t BASE_ALLOCATED = 4228;
+ constexpr size_t BASE_USED = 308;
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) + BASE, m.allocatedBytes());
- EXPECT_EQ(4 * sizeof(int) + BASE, m.usedBytes());
+ EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE_ALLOCATED, m.allocatedBytes());
+ EXPECT_EQ(4 * sizeof(int) + BASE_USED, 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) + BASE, m.allocatedBytes());
- EXPECT_EQ(4 * sizeof(int) + BASE, m.usedBytes());
+ EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE_ALLOCATED, m.allocatedBytes());
+ EXPECT_EQ(4 * sizeof(int) + BASE_USED, 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) + BASE, m.allocatedBytes());
- EXPECT_EQ(4 * sizeof(int) + BASE, m.usedBytes());
+ EXPECT_EQ(MyRef::offsetSize() * sizeof(int) + BASE_ALLOCATED, m.allocatedBytes());
+ EXPECT_EQ(4 * sizeof(int) + BASE_USED, m.usedBytes());
EXPECT_EQ(2 * sizeof(int), m.deadBytes());
EXPECT_EQ(1 * sizeof(int), m.allocatedBytesOnHold());
s.assign_generation(100);
@@ -538,7 +540,7 @@ void assertGrowStats(GrowthStats expSizes,
TEST(DataStoreTest, require_that_buffer_growth_works)
{
- constexpr size_t BASE = 41032u;
+ constexpr size_t BASE = 10312;
// Always switch to new buffer, min size 4
assertGrowStats({ 4, 4, 4, 4, 8, 16, 16, 32, 64, 64 },
{ 4 }, 20 + BASE, 4, 0);
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 cf62d238d53..1781a680bac 100644
--- a/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
+++ b/vespalib/src/tests/datastore/unique_store/unique_store_test.cpp
@@ -470,14 +470,14 @@ TEST_F(DoubleTest, nan_is_handled)
}
TEST_F(DoubleTest, control_memory_usage) {
- EXPECT_EQ(464, sizeof(store));
+ EXPECT_EQ(456u, sizeof(store));
EXPECT_EQ(144u, sizeof(BufferState));
- 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());
+ EXPECT_EQ(28740u, store.get_values_memory_usage().allocatedBytes());
+ EXPECT_EQ(24804u, store.get_values_memory_usage().usedBytes());
+ EXPECT_EQ(126952u, store.get_dictionary_memory_usage().allocatedBytes());
+ EXPECT_EQ(25248u, store.get_dictionary_memory_usage().usedBytes());
+ EXPECT_EQ(155692u, store.getMemoryUsage().allocatedBytes());
+ EXPECT_EQ(50052, store.getMemoryUsage().usedBytes());
}
GTEST_MAIN_RUN_ALL_TESTS()