From 1dd7760513806bf9b24dcc3aad744789ca320a46 Mon Sep 17 00:00:00 2001 From: Andrew Kryczka Date: Wed, 19 Apr 2017 11:44:40 -0700 Subject: [PATCH] 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 --- db/version_set.cc | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/db/version_set.cc b/db/version_set.cc index 9696f8107..5ae301a2d 100644 --- a/db/version_set.cc +++ b/db/version_set.cc @@ -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(total_size) / base_level_max_bytes); + score, static_cast(total_size) / + mutable_cf_options.max_bytes_for_level_base); } } } else {