Change L0 compaction score using level size

Summary:
The goal is to avoid the problem of small number of L0 files triggering compaction to base level (which increased write-amp), while still allowing L0 compaction-by-size (so intra-L0 compactions cause score to increase).
Closes https://github.com/facebook/rocksdb/pull/2172

Differential Revision: D4908552

Pulled By: ajkr

fbshipit-source-id: 4b170142b2b368e24bd7948b2a6f24c69fabf73d
This commit is contained in:
Andrew Kryczka 2017-04-19 11:44:40 -07:00 committed by Facebook Github Bot
parent 927bbab25c
commit 1dd7760513

View File

@ -1314,9 +1314,9 @@ void VersionStorageInfo::ComputeCompactionScore(
// Level-based involves L0->L0 compactions that can lead to oversized
// L0 files. Take into account size as well to avoid later giant
// compactions to the base level.
uint64_t base_level_max_bytes = MaxBytesForLevel(base_level());
score = std::max(
score, static_cast<double>(total_size) / base_level_max_bytes);
score, static_cast<double>(total_size) /
mutable_cf_options.max_bytes_for_level_base);
}
}
} else {