From 65a9cd616876c7a1204e1a50990400e4e1f61d7e Mon Sep 17 00:00:00 2001 From: PhaniShekhar Date: Thu, 21 Sep 2017 15:50:46 -0700 Subject: [PATCH] Use L1 size as estimate for L0 size in LevelCompactionBuilder::GetPathID Summary: Fix for [2461](https://github.com/facebook/rocksdb/issues/2461). Problem: When using multiple db_paths setting with RocksDB, RocksDB incorrectly calculates the size of L1 in LevelCompactionBuilder::GetPathId. max_bytes_for_level_base is used as L0 size and L1 size is calculated as (L0 size * max_bytes_for_level_multiplier). However, L1 size should be max_bytes_for_level_base. Solution: Use max_bytes_for_level_base as L1 size. Also, use L1 size as the estimated size of L0. Closes https://github.com/facebook/rocksdb/pull/2903 Differential Revision: D5885442 Pulled By: maysamyabandeh fbshipit-source-id: 036da1c9298d173b9b80479cc6661ee4b7a951f6 --- db/compaction_picker.cc | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/db/compaction_picker.cc b/db/compaction_picker.cc index a3fafe67f..5971d0eae 100644 --- a/db/compaction_picker.cc +++ b/db/compaction_picker.cc @@ -1268,6 +1268,8 @@ uint32_t LevelCompactionBuilder::GetPathId( uint64_t level_size; int cur_level = 0; + // max_bytes_for_level_base denotes L1 size. + // We estimate L0 size to be the same as L1. level_size = mutable_cf_options.max_bytes_for_level_base; // Last path is the fallback @@ -1278,8 +1280,10 @@ uint32_t LevelCompactionBuilder::GetPathId( return p; } else { current_path_size -= level_size; - level_size = static_cast( - level_size * mutable_cf_options.max_bytes_for_level_multiplier); + if (cur_level > 0) { + level_size = static_cast( + level_size * mutable_cf_options.max_bytes_for_level_multiplier); + } cur_level++; continue; }