summaryrefslogtreecommitdiff
path: root/util
diff options
context:
space:
mode:
authorVenkatesh Radhakrishnan <rven@fb.com>2016-01-28 11:56:16 -0800
committersdong <siying.d@fb.com>2016-01-29 16:15:53 -0800
commit3b2a1ddd2e9ca0998aa711644258675324febf6a (patch)
treed69b859d635d5fae239a4f09024bcc375aec5a4f /util
parent6ee38bb15c5421f4089e680ba67054cc14540b9d (diff)
Add options.base_background_compactions as a number of compaction threads for low compaction debt
Summary: If options.base_background_compactions is given, we try to schedule number of compactions not existing this number, only when L0 files increase to certain number, or pending compaction bytes more than certain threshold, we schedule compactions based on options.max_background_compactions. The watermarks are calculated based on slowdown thresholds. Test Plan: Add new test cases in column_family_test. Adding more unit tests. Reviewers: IslamAbdelRahman, yhchiang, kradhakrishnan, rven, anthony Reviewed By: anthony Subscribers: leveldb, dhruba, yoshinorim Differential Revision: https://reviews.facebook.net/D53409
Diffstat (limited to 'util')
-rw-r--r--util/options.cc5
-rw-r--r--util/options_helper.h5
-rw-r--r--util/options_test.cc45
3 files changed, 10 insertions, 45 deletions
diff --git a/util/options.cc b/util/options.cc
index d21d2a24b..00d797167 100644
--- a/util/options.cc
+++ b/util/options.cc
@@ -229,6 +229,7 @@ DBOptions::DBOptions()
db_log_dir(""),
wal_dir(""),
delete_obsolete_files_period_micros(6ULL * 60 * 60 * 1000000),
+ base_background_compactions(-1),
max_background_compactions(1),
max_subcompactions(1),
max_background_flushes(1),
@@ -295,6 +296,7 @@ DBOptions::DBOptions(const Options& options)
wal_dir(options.wal_dir),
delete_obsolete_files_period_micros(
options.delete_obsolete_files_period_micros),
+ base_background_compactions(options.base_background_compactions),
max_background_compactions(options.max_background_compactions),
max_subcompactions(options.max_subcompactions),
max_background_flushes(options.max_background_flushes),
@@ -383,6 +385,8 @@ void DBOptions::Dump(Logger* log) const {
table_cache_numshardbits);
Header(log, " Options.delete_obsolete_files_period_micros: %" PRIu64,
delete_obsolete_files_period_micros);
+ Header(log, " Options.base_background_compactions: %d",
+ base_background_compactions);
Header(log, " Options.max_background_compactions: %d",
max_background_compactions);
Header(log, " Options.max_subcompactions: %" PRIu32,
@@ -652,6 +656,7 @@ Options::PrepareForBulkLoad()
// to L1. This is helpful so that all files that are
// input to the manual compaction are all at L0.
max_background_compactions = 2;
+ base_background_compactions = 2;
// The compaction would create large files in L1.
target_file_size_base = 256 * 1024 * 1024;
diff --git a/util/options_helper.h b/util/options_helper.h
index 84d547cfc..4c4555aca 100644
--- a/util/options_helper.h
+++ b/util/options_helper.h
@@ -208,7 +208,7 @@ static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
{offsetof(struct DBOptions, random_access_max_buffer_size),
OptionType::kSizeT, OptionVerificationType::kNormal}},
{"writable_file_max_buffer_size",
- {offsetof(struct DBOptions, writable_file_max_buffer_size),
+ {offsetof(struct DBOptions, writable_file_max_buffer_size),
OptionType::kSizeT, OptionVerificationType::kNormal}},
{"use_adaptive_mutex",
{offsetof(struct DBOptions, use_adaptive_mutex), OptionType::kBoolean,
@@ -219,6 +219,9 @@ static std::unordered_map<std::string, OptionTypeInfo> db_options_type_info = {
{"max_background_compactions",
{offsetof(struct DBOptions, max_background_compactions), OptionType::kInt,
OptionVerificationType::kNormal}},
+ {"base_background_compactions",
+ {offsetof(struct DBOptions, base_background_compactions), OptionType::kInt,
+ OptionVerificationType::kNormal}},
{"max_background_flushes",
{offsetof(struct DBOptions, max_background_flushes), OptionType::kInt,
OptionVerificationType::kNormal}},
diff --git a/util/options_test.cc b/util/options_test.cc
index 65c45c2b0..961593bd0 100644
--- a/util/options_test.cc
+++ b/util/options_test.cc
@@ -1669,50 +1669,7 @@ TEST_F(OptionsParserTest, DBOptionsAllFieldsSettable) {
"table_cache_numshardbits=28;"
"max_open_files=72;"
"max_file_opening_threads=35;"
- "max_background_compactions=33;"
- "use_fsync=true;"
- "use_adaptive_mutex=false;"
- "max_total_wal_size=4295005604;"
- "compaction_readahead_size=0;"
- "new_table_reader_for_compaction_inputs=false;"
- "keep_log_file_num=4890;"
- "skip_stats_update_on_db_open=false;"
- "max_manifest_file_size=4295009941;"
- "db_log_dir=path/to/db_log_dir;"
- "skip_log_error_on_recovery=true;"
- "writable_file_max_buffer_size=1048576;"
- "paranoid_checks=true;"
- "is_fd_close_on_exec=false;"
- "bytes_per_sync=4295013613;"
- "enable_thread_tracking=false;"
- "disable_data_sync=false;"
- "recycle_log_file_num=0;"
- "disableDataSync=false;"
- "create_missing_column_families=true;"
- "log_file_time_to_roll=3097;"
- "max_background_flushes=35;"
- "create_if_missing=false;"
- "error_if_exists=true;"
- "allow_os_buffer=false;"
- "delayed_write_rate=4294976214;"
- "manifest_preallocation_size=1222;"
- "allow_mmap_writes=false;"
- "stats_dump_period_sec=70127;"
- "allow_fallocate=true;"
- "allow_mmap_reads=false;"
- "max_log_file_size=4607;"
- "random_access_max_buffer_size=1048576;"
- "advise_random_on_open=true;"
- "wal_bytes_per_sync=4295048118;"
- "delete_obsolete_files_period_micros=4294967758;"
- "WAL_ttl_seconds=4295008036;"
- "WAL_size_limit_MB=4295036161;"
- "wal_dir=path/to/wal_dir;"
- "db_write_buffer_size=2587;"
- "max_subcompactions=64330;"
- "table_cache_numshardbits=28;"
- "max_open_files=72;"
- "max_file_opening_threads=35;"
+ "base_background_compactions=3;"
"max_background_compactions=33;"
"use_fsync=true;"
"use_adaptive_mutex=false;"