aboutsummaryrefslogtreecommitdiffstats
path: root/vespalib/src/tests/datastore/array_store
diff options
context:
space:
mode:
authorTor Egge <Tor.Egge@online.no>2022-02-11 10:21:33 +0100
committerTor Egge <Tor.Egge@online.no>2022-02-11 10:21:33 +0100
commit80c0e1b687bbe57f5fdbb501580a8cb05af47804 (patch)
treed35087e4991fb6ed721ec7d52969d8e5b5948e6d /vespalib/src/tests/datastore/array_store
parent8a7c09b8628a9f3253f8dc00fe31947843b2600b (diff)
Add memory allocator to array store.
Diffstat (limited to 'vespalib/src/tests/datastore/array_store')
-rw-r--r--vespalib/src/tests/datastore/array_store/array_store_test.cpp20
1 files changed, 16 insertions, 4 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 c58e357a9a1..7c9f0770a17 100644
--- a/vespalib/src/tests/datastore/array_store/array_store_test.cpp
+++ b/vespalib/src/tests/datastore/array_store/array_store_test.cpp
@@ -7,6 +7,7 @@
#include <vespa/vespalib/datastore/compaction_strategy.h>
#include <vespa/vespalib/stllike/hash_map.hpp>
#include <vespa/vespalib/testkit/testapp.h>
+#include <vespa/vespalib/test/memory_allocator_observer.h>
#include <vespa/vespalib/test/insertion_operators.h>
#include <vespa/vespalib/util/memory_allocator.h>
#include <vespa/vespalib/util/size_literals.h>
@@ -19,6 +20,9 @@ using vespalib::ArrayRef;
using generation_t = vespalib::GenerationHandler::generation_t;
using MemStats = vespalib::datastore::test::MemStats;
using BufferStats = vespalib::datastore::test::BufferStats;
+using vespalib::alloc::MemoryAllocator;
+using vespalib::alloc::test::MemoryAllocatorObserver;
+using AllocStats = MemoryAllocatorObserver::Stats;
namespace {
@@ -40,18 +44,21 @@ struct Fixture
using value_type = EntryT;
using ReferenceStore = vespalib::hash_map<EntryRef, EntryVector>;
+ AllocStats stats;
ArrayStoreType store;
ReferenceStore refStore;
generation_t generation;
Fixture(uint32_t maxSmallArraySize, bool enable_free_lists = true)
- : store(ArrayStoreConfig(maxSmallArraySize,
+ : store(std::make_unique<MemoryAllocatorObserver>(stats),
+ ArrayStoreConfig(maxSmallArraySize,
ArrayStoreConfig::AllocSpec(16, RefT::offsetSize(), 8_Ki,
ALLOC_GROW_FACTOR)).enable_free_lists(enable_free_lists)),
refStore(),
generation(1)
{}
Fixture(const ArrayStoreConfig &storeCfg)
- : store(storeCfg),
+ : store(std::make_unique<MemoryAllocatorObserver>(stats),
+ storeCfg),
refStore(),
generation(1)
{}
@@ -162,10 +169,10 @@ TEST("require that we test with trivial and non-trivial types")
TEST_F("control static sizes", NumberFixture(3)) {
#ifdef _LIBCPP_VERSION
- EXPECT_EQUAL(424u, sizeof(f.store));
+ EXPECT_EQUAL(440u, sizeof(f.store));
EXPECT_EQUAL(296u, sizeof(NumberFixture::ArrayStoreType::DataStoreType));
#else
- EXPECT_EQUAL(456u, sizeof(f.store));
+ EXPECT_EQUAL(472u, sizeof(f.store));
EXPECT_EQUAL(328u, sizeof(NumberFixture::ArrayStoreType::DataStoreType));
#endif
EXPECT_EQUAL(96u, sizeof(NumberFixture::ArrayStoreType::SmallArrayType));
@@ -447,4 +454,9 @@ TEST_F("require that offset in EntryRefT is within bounds when allocating memory
f.assertStoreContent();
}
+TEST_F("require that provided memory allocator is used", NumberFixture(3))
+{
+ EXPECT_EQUAL(AllocStats(4, 0), f.stats);
+}
+
TEST_MAIN() { TEST_RUN_ALL(); }