account for L0 size in estimated compaction bytes
Summary: also changed the `>` in the comparison against `level0_file_num_compaction_trigger` into a `>=` since exactly `level0_file_num_compaction_trigger` can trigger a compaction from L0. Closes https://github.com/facebook/rocksdb/pull/2179 Differential Revision: D4915772 Pulled By: ajkr fbshipit-source-id: e38fec6253de6f9a40e61734615c6670d84038aa
This commit is contained in:
parent
0fae3f5dd3
commit
3a8a848a55
@ -952,7 +952,7 @@ TEST_F(CompactionPickerTest, NotScheduleL1IfL0WithHigherPri3) {
|
||||
TEST_F(CompactionPickerTest, EstimateCompactionBytesNeeded1) {
|
||||
int num_levels = ioptions_.num_levels;
|
||||
ioptions_.level_compaction_dynamic_level_bytes = false;
|
||||
mutable_cf_options_.level0_file_num_compaction_trigger = 3;
|
||||
mutable_cf_options_.level0_file_num_compaction_trigger = 4;
|
||||
mutable_cf_options_.max_bytes_for_level_base = 1000;
|
||||
mutable_cf_options_.max_bytes_for_level_multiplier = 10;
|
||||
NewVersionStorage(num_levels, kCompactionStyleLevel);
|
||||
|
@ -913,7 +913,7 @@ TEST_F(DBPropertiesTest, EstimatePendingCompBytes) {
|
||||
Flush();
|
||||
ASSERT_TRUE(dbfull()->GetIntProperty(
|
||||
"rocksdb.estimate-pending-compaction-bytes", &int_num));
|
||||
ASSERT_EQ(int_num, 0U);
|
||||
ASSERT_GT(int_num, 0U);
|
||||
|
||||
ASSERT_OK(dbfull()->Put(writeOpt, "k3", big_value));
|
||||
Flush();
|
||||
|
@ -1230,15 +1230,18 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
|
||||
// accumulated bytes.
|
||||
|
||||
uint64_t bytes_compact_to_next_level = 0;
|
||||
uint64_t level_size = 0;
|
||||
for (auto* f : files_[0]) {
|
||||
level_size += f->fd.GetFileSize();
|
||||
}
|
||||
// Level 0
|
||||
bool level0_compact_triggered = false;
|
||||
if (static_cast<int>(files_[0].size()) >
|
||||
mutable_cf_options.level0_file_num_compaction_trigger) {
|
||||
if (static_cast<int>(files_[0].size()) >=
|
||||
mutable_cf_options.level0_file_num_compaction_trigger ||
|
||||
level_size >= mutable_cf_options.max_bytes_for_level_base) {
|
||||
level0_compact_triggered = true;
|
||||
for (auto* f : files_[0]) {
|
||||
bytes_compact_to_next_level += f->fd.GetFileSize();
|
||||
}
|
||||
estimated_compaction_needed_bytes_ = bytes_compact_to_next_level;
|
||||
estimated_compaction_needed_bytes_ = level_size;
|
||||
bytes_compact_to_next_level = level_size;
|
||||
} else {
|
||||
estimated_compaction_needed_bytes_ = 0;
|
||||
}
|
||||
@ -1246,7 +1249,7 @@ void VersionStorageInfo::EstimateCompactionBytesNeeded(
|
||||
// Level 1 and up.
|
||||
uint64_t bytes_next_level = 0;
|
||||
for (int level = base_level(); level <= MaxInputLevel(); level++) {
|
||||
uint64_t level_size = 0;
|
||||
level_size = 0;
|
||||
if (bytes_next_level > 0) {
|
||||
#ifndef NDEBUG
|
||||
uint64_t level_size2 = 0;
|
||||
|
Loading…
Reference in New Issue
Block a user