2014-09-17 21:49:13 +02:00
|
|
|
// Copyright (c) 2014, Facebook, Inc. All rights reserved.
|
|
|
|
// This source code is licensed under the BSD-style license found in the
|
|
|
|
// LICENSE file in the root directory of this source tree. An additional grant
|
|
|
|
// of patent rights can be found in the PATENTS file in the same directory.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
#include <vector>
|
2014-09-17 21:49:13 +02:00
|
|
|
#include "rocksdb/options.h"
|
2014-10-02 01:19:16 +02:00
|
|
|
#include "rocksdb/immutable_options.h"
|
2014-09-17 21:49:13 +02:00
|
|
|
|
|
|
|
namespace rocksdb {
|
|
|
|
|
|
|
|
struct MutableCFOptions {
|
2014-10-02 01:19:16 +02:00
|
|
|
MutableCFOptions(const Options& options, const ImmutableCFOptions& ioptions)
|
2014-09-17 21:49:13 +02:00
|
|
|
: write_buffer_size(options.write_buffer_size),
|
2014-10-17 01:57:59 +02:00
|
|
|
max_write_buffer_number(options.max_write_buffer_number),
|
2014-09-17 21:49:13 +02:00
|
|
|
arena_block_size(options.arena_block_size),
|
|
|
|
memtable_prefix_bloom_bits(options.memtable_prefix_bloom_bits),
|
|
|
|
memtable_prefix_bloom_probes(options.memtable_prefix_bloom_probes),
|
|
|
|
memtable_prefix_bloom_huge_page_tlb_size(
|
|
|
|
options.memtable_prefix_bloom_huge_page_tlb_size),
|
|
|
|
max_successive_merges(options.max_successive_merges),
|
2014-10-02 01:19:16 +02:00
|
|
|
filter_deletes(options.filter_deletes),
|
2014-10-27 20:10:13 +01:00
|
|
|
inplace_update_num_locks(options.inplace_update_num_locks),
|
2014-10-17 02:14:17 +02:00
|
|
|
disable_auto_compactions(options.disable_auto_compactions),
|
2014-10-17 02:21:31 +02:00
|
|
|
soft_rate_limit(options.soft_rate_limit),
|
|
|
|
hard_rate_limit(options.hard_rate_limit),
|
2014-10-02 01:19:16 +02:00
|
|
|
level0_file_num_compaction_trigger(
|
|
|
|
options.level0_file_num_compaction_trigger),
|
|
|
|
level0_slowdown_writes_trigger(options.level0_slowdown_writes_trigger),
|
|
|
|
level0_stop_writes_trigger(options.level0_stop_writes_trigger),
|
|
|
|
max_grandparent_overlap_factor(options.max_grandparent_overlap_factor),
|
|
|
|
expanded_compaction_factor(options.expanded_compaction_factor),
|
|
|
|
source_compaction_factor(options.source_compaction_factor),
|
|
|
|
target_file_size_base(options.target_file_size_base),
|
|
|
|
target_file_size_multiplier(options.target_file_size_multiplier),
|
|
|
|
max_bytes_for_level_base(options.max_bytes_for_level_base),
|
|
|
|
max_bytes_for_level_multiplier(options.max_bytes_for_level_multiplier),
|
|
|
|
max_bytes_for_level_multiplier_additional(
|
2014-10-24 00:34:21 +02:00
|
|
|
options.max_bytes_for_level_multiplier_additional),
|
2014-10-24 00:37:14 +02:00
|
|
|
max_mem_compaction_level(options.max_mem_compaction_level),
|
2014-11-18 19:20:10 +01:00
|
|
|
verify_checksums_in_compaction(options.verify_checksums_in_compaction),
|
2014-10-24 00:34:21 +02:00
|
|
|
max_sequential_skip_in_iterations(
|
|
|
|
options.max_sequential_skip_in_iterations)
|
2014-10-02 01:19:16 +02:00
|
|
|
{
|
|
|
|
RefreshDerivedOptions(ioptions);
|
2014-09-17 21:49:13 +02:00
|
|
|
}
|
|
|
|
MutableCFOptions()
|
|
|
|
: write_buffer_size(0),
|
2014-10-17 01:57:59 +02:00
|
|
|
max_write_buffer_number(0),
|
2014-09-17 21:49:13 +02:00
|
|
|
arena_block_size(0),
|
|
|
|
memtable_prefix_bloom_bits(0),
|
|
|
|
memtable_prefix_bloom_probes(0),
|
|
|
|
memtable_prefix_bloom_huge_page_tlb_size(0),
|
|
|
|
max_successive_merges(0),
|
2014-10-02 01:19:16 +02:00
|
|
|
filter_deletes(false),
|
2014-10-27 20:10:13 +01:00
|
|
|
inplace_update_num_locks(0),
|
2014-10-17 02:14:17 +02:00
|
|
|
disable_auto_compactions(false),
|
2014-10-17 02:21:31 +02:00
|
|
|
soft_rate_limit(0),
|
|
|
|
hard_rate_limit(0),
|
2014-10-02 01:19:16 +02:00
|
|
|
level0_file_num_compaction_trigger(0),
|
|
|
|
level0_slowdown_writes_trigger(0),
|
|
|
|
level0_stop_writes_trigger(0),
|
|
|
|
max_grandparent_overlap_factor(0),
|
|
|
|
expanded_compaction_factor(0),
|
|
|
|
source_compaction_factor(0),
|
|
|
|
target_file_size_base(0),
|
|
|
|
target_file_size_multiplier(0),
|
|
|
|
max_bytes_for_level_base(0),
|
2014-10-24 00:34:21 +02:00
|
|
|
max_bytes_for_level_multiplier(0),
|
2014-10-24 00:37:14 +02:00
|
|
|
max_mem_compaction_level(0),
|
2014-11-18 19:20:10 +01:00
|
|
|
verify_checksums_in_compaction(false),
|
2014-10-24 00:34:21 +02:00
|
|
|
max_sequential_skip_in_iterations(0)
|
2014-10-02 01:19:16 +02:00
|
|
|
{}
|
2014-09-17 21:49:13 +02:00
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
// Must be called after any change to MutableCFOptions
|
|
|
|
void RefreshDerivedOptions(const ImmutableCFOptions& ioptions);
|
|
|
|
|
|
|
|
// Get the max file size in a given level.
|
|
|
|
uint64_t MaxFileSizeForLevel(int level) const;
|
|
|
|
// Returns maximum total overlap bytes with grandparent
|
|
|
|
// level (i.e., level+2) before we stop building a single
|
|
|
|
// file in level->level+1 compaction.
|
|
|
|
uint64_t MaxGrandParentOverlapBytes(int level) const;
|
|
|
|
uint64_t ExpandedCompactionByteSizeLimit(int level) const;
|
|
|
|
|
2014-10-17 02:22:28 +02:00
|
|
|
void Dump(Logger* log) const;
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
// Memtable related options
|
2014-09-17 21:49:13 +02:00
|
|
|
size_t write_buffer_size;
|
2014-10-17 01:57:59 +02:00
|
|
|
int max_write_buffer_number;
|
2014-09-17 21:49:13 +02:00
|
|
|
size_t arena_block_size;
|
|
|
|
uint32_t memtable_prefix_bloom_bits;
|
|
|
|
uint32_t memtable_prefix_bloom_probes;
|
|
|
|
size_t memtable_prefix_bloom_huge_page_tlb_size;
|
|
|
|
size_t max_successive_merges;
|
|
|
|
bool filter_deletes;
|
2014-10-27 20:10:13 +01:00
|
|
|
size_t inplace_update_num_locks;
|
2014-10-02 01:19:16 +02:00
|
|
|
|
|
|
|
// Compaction related options
|
2014-10-17 02:14:17 +02:00
|
|
|
bool disable_auto_compactions;
|
2014-10-17 02:21:31 +02:00
|
|
|
double soft_rate_limit;
|
|
|
|
double hard_rate_limit;
|
2014-10-02 01:19:16 +02:00
|
|
|
int level0_file_num_compaction_trigger;
|
|
|
|
int level0_slowdown_writes_trigger;
|
|
|
|
int level0_stop_writes_trigger;
|
|
|
|
int max_grandparent_overlap_factor;
|
|
|
|
int expanded_compaction_factor;
|
|
|
|
int source_compaction_factor;
|
2014-11-11 22:47:22 +01:00
|
|
|
uint64_t target_file_size_base;
|
2014-10-02 01:19:16 +02:00
|
|
|
int target_file_size_multiplier;
|
|
|
|
uint64_t max_bytes_for_level_base;
|
|
|
|
int max_bytes_for_level_multiplier;
|
|
|
|
std::vector<int> max_bytes_for_level_multiplier_additional;
|
2014-10-24 00:37:14 +02:00
|
|
|
int max_mem_compaction_level;
|
2014-11-18 19:20:10 +01:00
|
|
|
bool verify_checksums_in_compaction;
|
2014-10-02 01:19:16 +02:00
|
|
|
|
2014-10-24 00:34:21 +02:00
|
|
|
// Misc options
|
|
|
|
uint64_t max_sequential_skip_in_iterations;
|
|
|
|
|
2014-10-02 01:19:16 +02:00
|
|
|
// Derived options
|
|
|
|
// Per-level target file size.
|
|
|
|
std::vector<uint64_t> max_file_size;
|
2014-09-17 21:49:13 +02:00
|
|
|
};
|
|
|
|
|
options.level_compaction_dynamic_level_bytes to allow RocksDB to pick size bases of levels dynamically.
Summary:
When having fixed max_bytes_for_level_base, the ratio of size of largest level and the second one can range from 0 to the multiplier. This makes LSM tree frequently irregular and unpredictable. It can also cause poor space amplification in some cases.
In this improvement (proposed by Igor Kabiljo), we introduce a parameter option.level_compaction_use_dynamic_max_bytes. When turning it on, RocksDB is free to pick a level base in the range of (options.max_bytes_for_level_base/options.max_bytes_for_level_multiplier, options.max_bytes_for_level_base] so that real level ratios are close to options.max_bytes_for_level_multiplier.
Test Plan: New unit tests and pass tests suites including valgrind.
Reviewers: MarkCallaghan, rven, yhchiang, igor, ikabiljo
Reviewed By: ikabiljo
Subscribers: yoshinorim, ikabiljo, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D31437
2015-02-05 20:44:17 +01:00
|
|
|
uint64_t MultiplyCheckOverflow(uint64_t op1, int op2);
|
|
|
|
|
2014-09-17 21:49:13 +02:00
|
|
|
} // namespace rocksdb
|