Skip to content

Commit

Permalink
fix(storage): fix compactor oom by count the memory for cache in comp…
Browse files Browse the repository at this point in the history
…actor (#16727)

Signed-off-by: MrCroxx <[email protected]>
  • Loading branch information
MrCroxx authored May 13, 2024
1 parent 8a9f29d commit 4fda5d7
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions src/storage/src/hummock/sstable_store.rs
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,7 @@ impl SstableStore {

/// For compactor, we do not need a high concurrency load for cache. Instead, we need the cache
/// can be evict more effective.
#[expect(clippy::borrowed_box)]
pub async fn for_compactor(
store: ObjectStoreRef,
path: String,
Expand All @@ -149,6 +150,9 @@ impl SstableStore {
let meta_cache_v2 = HybridCacheBuilder::new()
.memory(meta_cache_capacity)
.with_shards(1)
.with_weighter(|_: &HummockSstableObjectId, value: &Box<Sstable>| {
u64::BITS as usize / 8 + value.estimate_size()
})
.storage()
.build()
.await
Expand All @@ -157,6 +161,10 @@ impl SstableStore {
let block_cache_v2 = HybridCacheBuilder::new()
.memory(block_cache_capacity)
.with_shards(1)
.with_weighter(|_: &SstableBlockIndex, value: &Box<Block>| {
// FIXME(MrCroxx): Calculate block weight more accurately.
u64::BITS as usize * 2 / 8 + value.raw().len()
})
.storage()
.build()
.await
Expand Down

0 comments on commit 4fda5d7

Please sign in to comment.