summaryrefslogtreecommitdiff
path: root/memtable
diff options
context:
space:
mode:
authorMaysam Yabandeh <myabandeh@fb.com>2019-09-16 15:14:51 -0700
committerFacebook Github Bot <facebook-github-bot@users.noreply.github.com>2019-09-16 15:26:21 -0700
commit638d23950716f3119057d725fbbf1590b807a849 (patch)
tree616150272a7fe360e8a29d592d1f3aaca0b3d887 /memtable
parent94d62d771e627a184711a5e634a7cfefa52b12d2 (diff)
Charge block cache for cache internal usage (#5797)
Summary: For our default block cache, each additional entry has extra memory overhead. It include LRUHandle (72 bytes currently) and the cache key (two varint64, file id and offset). The usage is not negligible. For example for block_size=4k, the overhead accounts for an extra 2% memory usage for the cache. The patch charging the cache for the extra usage, reducing untracked memory usage outside block cache. The feature is enabled by default and can be disabled by passing kDontChargeCacheMetadata to the cache constructor. This PR builds up on https://github.com/facebook/rocksdb/issues/4258 Pull Request resolved: https://github.com/facebook/rocksdb/pull/5797 Test Plan: - Existing tests are updated to either disable the feature when the test has too much dependency on the old way of accounting the usage or increasing the cache capacity to account for the additional charge of metadata. - The Usage tests in cache_test.cc are augmented to test the cache usage under kFullChargeCacheMetadata. Differential Revision: D17396833 Pulled By: maysamyabandeh fbshipit-source-id: 7684ccb9f8a40ca595e4f5efcdb03623afea0c6f
Diffstat (limited to 'memtable')
-rw-r--r--memtable/write_buffer_manager_test.cc6
1 files changed, 5 insertions, 1 deletions
diff --git a/memtable/write_buffer_manager_test.cc b/memtable/write_buffer_manager_test.cc
index 06514eabd..23de06a62 100644
--- a/memtable/write_buffer_manager_test.cc
+++ b/memtable/write_buffer_manager_test.cc
@@ -51,8 +51,12 @@ TEST_F(WriteBufferManagerTest, ShouldFlush) {
}
TEST_F(WriteBufferManagerTest, CacheCost) {
+ LRUCacheOptions co;
// 1GB cache
- std::shared_ptr<Cache> cache = NewLRUCache(1024 * 1024 * 1024, 4);
+ co.capacity = 1024 * 1024 * 1024;
+ co.num_shard_bits = 4;
+ co.metadata_charge_policy = kDontChargeCacheMetadata;
+ std::shared_ptr<Cache> cache = NewLRUCache(co);
// A write buffer manager of size 50MB
std::unique_ptr<WriteBufferManager> wbf(
new WriteBufferManager(50 * 1024 * 1024, cache));