Make compaction_pri = kMinOverlappingRatio to be default (#4911)

Summary:
compaction_pri = kMinOverlappingRatio usually provides much better write amplification than the default.
https://github.com/facebook/rocksdb/pull/4907 fixes one shortcome of this option. Make it default.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/4911

Differential Revision: D13789262

Pulled By: siying

fbshipit-source-id: d90acf8c4dede44f00d183ca4c7a210259378269
main
Siying Dong 6 years ago committed by Facebook Github Bot
parent 27054d837b
commit d94aa2f7db
  1. 3
      HISTORY.md
  2. 3
      db/compaction_picker_test.cc
  3. 4
      include/rocksdb/advanced_options.h
  4. 5
      options/options.cc
  5. 9
      options/options_test.cc

@ -23,6 +23,9 @@
* Fix incorrect `NotFound` point lookup result when querying the endpoint of a file that has been extended by a range tombstone. * Fix incorrect `NotFound` point lookup result when querying the endpoint of a file that has been extended by a range tombstone.
* Fix with pipelined write, write leaders's callback failure lead to the whole write group fail. * Fix with pipelined write, write leaders's callback failure lead to the whole write group fail.
### Change Default Options
* Change options.compaction_pri's default to kMinOverlappingRatio
## 5.18.0 (11/30/2018) ## 5.18.0 (11/30/2018)
### New Features ### New Features
* Introduced `JemallocNodumpAllocator` memory allocator. When being use, block cache will be excluded from core dump. * Introduced `JemallocNodumpAllocator` memory allocator. When being use, block cache will be excluded from core dump.

@ -59,6 +59,9 @@ class CompactionPickerTest : public testing::Test {
log_buffer_(InfoLogLevel::INFO_LEVEL, &logger_), log_buffer_(InfoLogLevel::INFO_LEVEL, &logger_),
file_num_(1), file_num_(1),
vstorage_(nullptr) { vstorage_(nullptr) {
// ioptions_.compaction_pri = kMinOverlappingRatio has its own set of
// tests to cover.
ioptions_.compaction_pri = kByCompensatedSize;
fifo_options_.max_table_files_size = 1; fifo_options_.max_table_files_size = 1;
mutable_cf_options_.RefreshDerivedOptions(ioptions_); mutable_cf_options_.RefreshDerivedOptions(ioptions_);
ioptions_.cf_paths.emplace_back("dummy", ioptions_.cf_paths.emplace_back("dummy",

@ -528,8 +528,8 @@ struct AdvancedColumnFamilyOptions {
// If level compaction_style = kCompactionStyleLevel, for each level, // If level compaction_style = kCompactionStyleLevel, for each level,
// which files are prioritized to be picked to compact. // which files are prioritized to be picked to compact.
// Default: kByCompensatedSize // Default: kMinOverlappingRatio
CompactionPri compaction_pri = kByCompensatedSize; CompactionPri compaction_pri = kMinOverlappingRatio;
// The options needed to support Universal Style compactions // The options needed to support Universal Style compactions
// //

@ -439,6 +439,10 @@ DBOptions* DBOptions::OldDefaults(int rocksdb_major_version,
ColumnFamilyOptions* ColumnFamilyOptions::OldDefaults( ColumnFamilyOptions* ColumnFamilyOptions::OldDefaults(
int rocksdb_major_version, int rocksdb_minor_version) { int rocksdb_major_version, int rocksdb_minor_version) {
if (rocksdb_major_version < 5 ||
(rocksdb_major_version == 5 && rocksdb_minor_version <= 18)) {
compaction_pri = CompactionPri::kByCompensatedSize;
}
if (rocksdb_major_version < 4 || if (rocksdb_major_version < 4 ||
(rocksdb_major_version == 4 && rocksdb_minor_version < 7)) { (rocksdb_major_version == 4 && rocksdb_minor_version < 7)) {
write_buffer_size = 4 << 20; write_buffer_size = 4 << 20;
@ -452,7 +456,6 @@ ColumnFamilyOptions* ColumnFamilyOptions::OldDefaults(
} else if (rocksdb_major_version == 5 && rocksdb_minor_version < 2) { } else if (rocksdb_major_version == 5 && rocksdb_minor_version < 2) {
level0_stop_writes_trigger = 30; level0_stop_writes_trigger = 30;
} }
compaction_pri = CompactionPri::kByCompensatedSize;
return this; return this;
} }

@ -1528,6 +1528,7 @@ TEST_F(OptionsParserTest, DifferentDefault) {
const std::string kOptionsFileName = "test-persisted-options.ini"; const std::string kOptionsFileName = "test-persisted-options.ini";
ColumnFamilyOptions cf_level_opts; ColumnFamilyOptions cf_level_opts;
ASSERT_EQ(CompactionPri::kMinOverlappingRatio, cf_level_opts.compaction_pri);
cf_level_opts.OptimizeLevelStyleCompaction(); cf_level_opts.OptimizeLevelStyleCompaction();
ColumnFamilyOptions cf_univ_opts; ColumnFamilyOptions cf_univ_opts;
@ -1597,6 +1598,14 @@ TEST_F(OptionsParserTest, DifferentDefault) {
Options old_default_opts; Options old_default_opts;
old_default_opts.OldDefaults(5, 2); old_default_opts.OldDefaults(5, 2);
ASSERT_EQ(16 * 1024U * 1024U, old_default_opts.delayed_write_rate); ASSERT_EQ(16 * 1024U * 1024U, old_default_opts.delayed_write_rate);
ASSERT_TRUE(old_default_opts.compaction_pri ==
CompactionPri::kByCompensatedSize);
}
{
Options old_default_opts;
old_default_opts.OldDefaults(5, 18);
ASSERT_TRUE(old_default_opts.compaction_pri ==
CompactionPri::kByCompensatedSize);
} }
Options small_opts; Options small_opts;

Loading…
Cancel
Save