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
main
PhaniShekhar 7 years ago committed by Facebook Github Bot
parent 8fc3de3c62
commit 65a9cd6168
  1. 4
      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;
if (cur_level > 0) {
level_size = static_cast<uint64_t>(
level_size * mutable_cf_options.max_bytes_for_level_multiplier);
}
cur_level++;
continue;
}

Loading…
Cancel
Save