Skip to content

Commit

Permalink
Use L1 size as estimate for L0 size in LevelCompactionBuilder::GetPathID
Browse files Browse the repository at this point in the history
Summary:
Fix for [2461](facebook#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 facebook#2903

Differential Revision: D5885442

Pulled By: maysamyabandeh

fbshipit-source-id: 036da1c9298d173b9b80479cc6661ee4b7a951f6
  • Loading branch information
PhaniShekhar authored and ifed01 committed Nov 30, 2017
1 parent bac0af3 commit 62782e7
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions db/compaction_picker.cc
Original file line number Diff line number Diff line change
Expand Up @@ -1251,6 +1251,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
Expand All @@ -1261,8 +1263,10 @@ uint32_t LevelCompactionBuilder::GetPathId(
return p;
} else {
current_path_size -= level_size;
level_size = static_cast<uint64_t>(
level_size * mutable_cf_options.max_bytes_for_level_multiplier);
if (cur_level > 0) {
level_size = static_cast<uint64_t>(
level_size * mutable_cf_options.max_bytes_for_level_multiplier);
}
cur_level++;
continue;
}
Expand Down

0 comments on commit 62782e7

Please sign in to comment.