aboutsummaryrefslogtreecommitdiffstats
path: root/searchlib
diff options
context:
space:
mode:
authorHenning Baldersheim <balder@yahoo-inc.com>2023-03-14 12:34:58 +0000
committerHenning Baldersheim <balder@yahoo-inc.com>2023-03-14 12:34:58 +0000
commit1e0598be29be3f42809ea84303129ffe2301ef3c (patch)
treee960be7ae2c0bfb46e2cba75936244c8f5d0702a /searchlib
parent28ab766a23032cf35c3a124007775712a4fd033e (diff)
Track static cache usage
Diffstat (limited to 'searchlib')
-rw-r--r--searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp4
-rw-r--r--searchlib/src/vespa/searchlib/docstore/visitcache.cpp12
2 files changed, 14 insertions, 2 deletions
diff --git a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
index c496472bdfa..a552573470e 100644
--- a/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
+++ b/searchlib/src/tests/docstore/logdatastore/logdatastore_test.cpp
@@ -564,8 +564,8 @@ TEST("Control static memory usage") {
VisitCacheStore vcs(DocumentStore::Config::UpdateStrategy::UPDATE);
IDocumentStore &ds = vcs.getStore();
vespalib::MemoryUsage usage = ds.getMemoryUsage();
- EXPECT_EQUAL(74116u, usage.allocatedBytes());
- EXPECT_EQUAL(392u, usage.usedBytes());
+ EXPECT_EQUAL(83700u, usage.allocatedBytes());
+ EXPECT_EQUAL(10072u, usage.usedBytes());
}
TEST("test the update cache strategy") {
diff --git a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
index d7c1a400b1e..dcd38d1fd04 100644
--- a/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
+++ b/searchlib/src/vespa/searchlib/docstore/visitcache.cpp
@@ -262,6 +262,18 @@ VisitCache::Cache::onRemove(const K & key) {
vespalib::MemoryUsage
VisitCache::Cache::getStaticMemoryUsage() const {
vespalib::MemoryUsage usage = Parent::getStaticMemoryUsage();
+ auto cacheGuard = getGuard();
+ size_t baseSelf = sizeof(_lid2Id) + sizeof(_id2KeySet);
+ usage.incAllocatedBytes(baseSelf);
+ usage.incAllocatedBytes(_lid2Id.capacity() * sizeof(LidUniqueKeySetId::value_type));
+ usage.incAllocatedBytes(_id2KeySet.capacity() * sizeof(IdKeySetMap::value_type));
+ usage.incUsedBytes(baseSelf);
+ usage.incAllocatedBytes(_lid2Id.size() * sizeof(LidUniqueKeySetId::value_type));
+ usage.incUsedBytes(_id2KeySet.size() * sizeof(IdKeySetMap::value_type));
+ for (const auto & entry: _id2KeySet) {
+ usage.incAllocatedBytes(entry.second.getKeys().capacity() * sizeof(uint32_t));
+ usage.incUsedBytes(entry.second.getKeys().size() * sizeof(uint32_t));
+ }
return usage;
}