fork of https://github.com/oxigraph/rocksdb and https://github.com/facebook/rocksdb for nextgraph and oxigraph
You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
615 lines
26 KiB
615 lines
26 KiB
9 years ago
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
||
11 years ago
|
// 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.
|
||
|
//
|
||
14 years ago
|
// Copyright (c) 2011 The LevelDB Authors. All rights reserved.
|
||
|
// Use of this source code is governed by a BSD-style license that can be
|
||
|
// found in the LICENSE file. See the AUTHORS file for names of contributors.
|
||
|
|
||
11 years ago
|
#include "rocksdb/options.h"
|
||
14 years ago
|
|
||
10 years ago
|
#ifndef __STDC_FORMAT_MACROS
|
||
11 years ago
|
#define __STDC_FORMAT_MACROS
|
||
10 years ago
|
#endif
|
||
|
|
||
11 years ago
|
#include <inttypes.h>
|
||
12 years ago
|
#include <limits>
|
||
|
|
||
8 years ago
|
#include "monitoring/statistics.h"
|
||
|
#include "options/db_options.h"
|
||
|
#include "options/options_helper.h"
|
||
11 years ago
|
#include "rocksdb/cache.h"
|
||
|
#include "rocksdb/compaction_filter.h"
|
||
|
#include "rocksdb/comparator.h"
|
||
|
#include "rocksdb/env.h"
|
||
11 years ago
|
#include "rocksdb/memtablerep.h"
|
||
11 years ago
|
#include "rocksdb/merge_operator.h"
|
||
11 years ago
|
#include "rocksdb/slice.h"
|
||
|
#include "rocksdb/slice_transform.h"
|
||
8 years ago
|
#include "rocksdb/sst_file_manager.h"
|
||
11 years ago
|
#include "rocksdb/table.h"
|
||
11 years ago
|
#include "rocksdb/table_properties.h"
|
||
9 years ago
|
#include "rocksdb/wal_filter.h"
|
||
11 years ago
|
#include "table/block_based_table_factory.h"
|
||
10 years ago
|
#include "util/compression.h"
|
||
14 years ago
|
|
||
11 years ago
|
namespace rocksdb {
|
||
14 years ago
|
|
||
8 years ago
|
AdvancedColumnFamilyOptions::AdvancedColumnFamilyOptions() {
|
||
11 years ago
|
assert(memtable_factory.get() != nullptr);
|
||
|
}
|
||
|
|
||
8 years ago
|
AdvancedColumnFamilyOptions::AdvancedColumnFamilyOptions(const Options& options)
|
||
|
: max_write_buffer_number(options.max_write_buffer_number),
|
||
11 years ago
|
min_write_buffer_number_to_merge(
|
||
|
options.min_write_buffer_number_to_merge),
|
||
10 years ago
|
max_write_buffer_number_to_maintain(
|
||
|
options.max_write_buffer_number_to_maintain),
|
||
8 years ago
|
inplace_update_support(options.inplace_update_support),
|
||
|
inplace_update_num_locks(options.inplace_update_num_locks),
|
||
|
inplace_callback(options.inplace_callback),
|
||
|
memtable_prefix_bloom_size_ratio(
|
||
|
options.memtable_prefix_bloom_size_ratio),
|
||
|
memtable_huge_page_size(options.memtable_huge_page_size),
|
||
|
memtable_insert_with_hint_prefix_extractor(
|
||
|
options.memtable_insert_with_hint_prefix_extractor),
|
||
|
bloom_locality(options.bloom_locality),
|
||
|
arena_block_size(options.arena_block_size),
|
||
11 years ago
|
compression_per_level(options.compression_per_level),
|
||
|
num_levels(options.num_levels),
|
||
|
level0_slowdown_writes_trigger(options.level0_slowdown_writes_trigger),
|
||
|
level0_stop_writes_trigger(options.level0_stop_writes_trigger),
|
||
|
target_file_size_base(options.target_file_size_base),
|
||
|
target_file_size_multiplier(options.target_file_size_multiplier),
|
||
10 years ago
|
level_compaction_dynamic_level_bytes(
|
||
|
options.level_compaction_dynamic_level_bytes),
|
||
11 years ago
|
max_bytes_for_level_multiplier(options.max_bytes_for_level_multiplier),
|
||
|
max_bytes_for_level_multiplier_additional(
|
||
|
options.max_bytes_for_level_multiplier_additional),
|
||
9 years ago
|
max_compaction_bytes(options.max_compaction_bytes),
|
||
9 years ago
|
soft_pending_compaction_bytes_limit(
|
||
|
options.soft_pending_compaction_bytes_limit),
|
||
9 years ago
|
hard_pending_compaction_bytes_limit(
|
||
|
options.hard_pending_compaction_bytes_limit),
|
||
11 years ago
|
compaction_style(options.compaction_style),
|
||
9 years ago
|
compaction_pri(options.compaction_pri),
|
||
11 years ago
|
compaction_options_universal(options.compaction_options_universal),
|
||
11 years ago
|
compaction_options_fifo(options.compaction_options_fifo),
|
||
11 years ago
|
max_sequential_skip_in_iterations(
|
||
|
options.max_sequential_skip_in_iterations),
|
||
|
memtable_factory(options.memtable_factory),
|
||
11 years ago
|
table_properties_collector_factories(
|
||
|
options.table_properties_collector_factories),
|
||
11 years ago
|
max_successive_merges(options.max_successive_merges),
|
||
10 years ago
|
optimize_filters_for_hits(options.optimize_filters_for_hits),
|
||
9 years ago
|
paranoid_file_checks(options.paranoid_file_checks),
|
||
8 years ago
|
force_consistency_checks(options.force_consistency_checks),
|
||
9 years ago
|
report_bg_io_stats(options.report_bg_io_stats) {
|
||
11 years ago
|
assert(memtable_factory.get() != nullptr);
|
||
11 years ago
|
if (max_bytes_for_level_multiplier_additional.size() <
|
||
|
static_cast<unsigned int>(num_levels)) {
|
||
11 years ago
|
max_bytes_for_level_multiplier_additional.resize(num_levels, 1);
|
||
|
}
|
||
11 years ago
|
}
|
||
|
|
||
8 years ago
|
ColumnFamilyOptions::ColumnFamilyOptions()
|
||
|
: compression(Snappy_Supported() ? kSnappyCompression : kNoCompression),
|
||
|
table_factory(
|
||
|
std::shared_ptr<TableFactory>(new BlockBasedTableFactory())) {}
|
||
|
|
||
|
ColumnFamilyOptions::ColumnFamilyOptions(const Options& options)
|
||
|
: AdvancedColumnFamilyOptions(options),
|
||
|
comparator(options.comparator),
|
||
|
merge_operator(options.merge_operator),
|
||
|
compaction_filter(options.compaction_filter),
|
||
|
compaction_filter_factory(options.compaction_filter_factory),
|
||
|
write_buffer_size(options.write_buffer_size),
|
||
|
compression(options.compression),
|
||
|
bottommost_compression(options.bottommost_compression),
|
||
|
compression_opts(options.compression_opts),
|
||
|
level0_file_num_compaction_trigger(
|
||
|
options.level0_file_num_compaction_trigger),
|
||
|
prefix_extractor(options.prefix_extractor),
|
||
|
max_bytes_for_level_base(options.max_bytes_for_level_base),
|
||
|
disable_auto_compactions(options.disable_auto_compactions),
|
||
|
table_factory(options.table_factory) {}
|
||
|
|
||
8 years ago
|
DBOptions::DBOptions() {}
|
||
14 years ago
|
|
||
11 years ago
|
DBOptions::DBOptions(const Options& options)
|
||
|
: create_if_missing(options.create_if_missing),
|
||
11 years ago
|
create_missing_column_families(options.create_missing_column_families),
|
||
11 years ago
|
error_if_exists(options.error_if_exists),
|
||
|
paranoid_checks(options.paranoid_checks),
|
||
|
env(options.env),
|
||
11 years ago
|
rate_limiter(options.rate_limiter),
|
||
9 years ago
|
sst_file_manager(options.sst_file_manager),
|
||
11 years ago
|
info_log(options.info_log),
|
||
11 years ago
|
info_log_level(options.info_log_level),
|
||
11 years ago
|
max_open_files(options.max_open_files),
|
||
9 years ago
|
max_file_opening_threads(options.max_file_opening_threads),
|
||
11 years ago
|
max_total_wal_size(options.max_total_wal_size),
|
||
11 years ago
|
statistics(options.statistics),
|
||
11 years ago
|
use_fsync(options.use_fsync),
|
||
11 years ago
|
db_paths(options.db_paths),
|
||
11 years ago
|
db_log_dir(options.db_log_dir),
|
||
|
wal_dir(options.wal_dir),
|
||
|
delete_obsolete_files_period_micros(
|
||
|
options.delete_obsolete_files_period_micros),
|
||
9 years ago
|
base_background_compactions(options.base_background_compactions),
|
||
11 years ago
|
max_background_compactions(options.max_background_compactions),
|
||
9 years ago
|
max_subcompactions(options.max_subcompactions),
|
||
11 years ago
|
max_background_flushes(options.max_background_flushes),
|
||
|
max_log_file_size(options.max_log_file_size),
|
||
|
log_file_time_to_roll(options.log_file_time_to_roll),
|
||
|
keep_log_file_num(options.keep_log_file_num),
|
||
9 years ago
|
recycle_log_file_num(options.recycle_log_file_num),
|
||
11 years ago
|
max_manifest_file_size(options.max_manifest_file_size),
|
||
11 years ago
|
table_cache_numshardbits(options.table_cache_numshardbits),
|
||
11 years ago
|
WAL_ttl_seconds(options.WAL_ttl_seconds),
|
||
|
WAL_size_limit_MB(options.WAL_size_limit_MB),
|
||
|
manifest_preallocation_size(options.manifest_preallocation_size),
|
||
|
allow_mmap_reads(options.allow_mmap_reads),
|
||
|
allow_mmap_writes(options.allow_mmap_writes),
|
||
8 years ago
|
use_direct_reads(options.use_direct_reads),
|
||
8 years ago
|
use_direct_writes(options.use_direct_writes),
|
||
9 years ago
|
allow_fallocate(options.allow_fallocate),
|
||
11 years ago
|
is_fd_close_on_exec(options.is_fd_close_on_exec),
|
||
|
skip_log_error_on_recovery(options.skip_log_error_on_recovery),
|
||
|
stats_dump_period_sec(options.stats_dump_period_sec),
|
||
|
advise_random_on_open(options.advise_random_on_open),
|
||
10 years ago
|
db_write_buffer_size(options.db_write_buffer_size),
|
||
9 years ago
|
write_buffer_manager(options.write_buffer_manager),
|
||
11 years ago
|
access_hint_on_compaction_start(options.access_hint_on_compaction_start),
|
||
9 years ago
|
new_table_reader_for_compaction_inputs(
|
||
|
options.new_table_reader_for_compaction_inputs),
|
||
9 years ago
|
compaction_readahead_size(options.compaction_readahead_size),
|
||
9 years ago
|
random_access_max_buffer_size(options.random_access_max_buffer_size),
|
||
9 years ago
|
writable_file_max_buffer_size(options.writable_file_max_buffer_size),
|
||
11 years ago
|
use_adaptive_mutex(options.use_adaptive_mutex),
|
||
10 years ago
|
bytes_per_sync(options.bytes_per_sync),
|
||
10 years ago
|
wal_bytes_per_sync(options.wal_bytes_per_sync),
|
||
10 years ago
|
listeners(options.listeners),
|
||
10 years ago
|
enable_thread_tracking(options.enable_thread_tracking),
|
||
10 years ago
|
delayed_write_rate(options.delayed_write_rate),
|
||
9 years ago
|
allow_concurrent_memtable_write(options.allow_concurrent_memtable_write),
|
||
|
enable_write_thread_adaptive_yield(
|
||
|
options.enable_write_thread_adaptive_yield),
|
||
|
write_thread_max_yield_usec(options.write_thread_max_yield_usec),
|
||
|
write_thread_slow_yield_usec(options.write_thread_slow_yield_usec),
|
||
9 years ago
|
skip_stats_update_on_db_open(options.skip_stats_update_on_db_open),
|
||
10 years ago
|
wal_recovery_mode(options.wal_recovery_mode),
|
||
9 years ago
|
row_cache(options.row_cache),
|
||
9 years ago
|
#ifndef ROCKSDB_LITE
|
||
9 years ago
|
wal_filter(options.wal_filter),
|
||
9 years ago
|
#endif // ROCKSDB_LITE
|
||
9 years ago
|
fail_if_options_file_error(options.fail_if_options_file_error),
|
||
9 years ago
|
dump_malloc_stats(options.dump_malloc_stats),
|
||
8 years ago
|
avoid_flush_during_recovery(options.avoid_flush_during_recovery),
|
||
|
avoid_flush_during_shutdown(options.avoid_flush_during_shutdown) {
|
||
9 years ago
|
}
|
||
11 years ago
|
|
||
11 years ago
|
void DBOptions::Dump(Logger* log) const {
|
||
8 years ago
|
ImmutableDBOptions(*this).Dump(log);
|
||
|
MutableDBOptions(*this).Dump(log);
|
||
11 years ago
|
} // DBOptions::Dump
|
||
|
|
||
|
void ColumnFamilyOptions::Dump(Logger* log) const {
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, " Options.comparator: %s",
|
||
|
comparator->Name());
|
||
|
ROCKS_LOG_HEADER(log, " Options.merge_operator: %s",
|
||
|
merge_operator ? merge_operator->Name() : "None");
|
||
|
ROCKS_LOG_HEADER(log, " Options.compaction_filter: %s",
|
||
|
compaction_filter ? compaction_filter->Name() : "None");
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.compaction_filter_factory: %s",
|
||
10 years ago
|
compaction_filter_factory ? compaction_filter_factory->Name() : "None");
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, " Options.memtable_factory: %s",
|
||
|
memtable_factory->Name());
|
||
|
ROCKS_LOG_HEADER(log, " Options.table_factory: %s",
|
||
|
table_factory->Name());
|
||
|
ROCKS_LOG_HEADER(log, " table_factory options: %s",
|
||
|
table_factory->GetPrintableTableOptions().c_str());
|
||
|
ROCKS_LOG_HEADER(log, " Options.write_buffer_size: %" ROCKSDB_PRIszt,
|
||
|
write_buffer_size);
|
||
|
ROCKS_LOG_HEADER(log, " Options.max_write_buffer_number: %d",
|
||
|
max_write_buffer_number);
|
||
|
if (!compression_per_level.empty()) {
|
||
|
for (unsigned int i = 0; i < compression_per_level.size(); i++) {
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.compression[%d]: %s", i,
|
||
|
CompressionTypeToString(compression_per_level[i]).c_str());
|
||
|
}
|
||
12 years ago
|
} else {
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, " Options.compression: %s",
|
||
|
CompressionTypeToString(compression).c_str());
|
||
12 years ago
|
}
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.bottommost_compression: %s",
|
||
|
bottommost_compression == kDisableCompressionOption
|
||
|
? "Disabled"
|
||
|
: CompressionTypeToString(bottommost_compression).c_str());
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.prefix_extractor: %s",
|
||
11 years ago
|
prefix_extractor == nullptr ? "nullptr" : prefix_extractor->Name());
|
||
8 years ago
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.memtable_insert_with_hint_prefix_extractor: %s",
|
||
|
memtable_insert_with_hint_prefix_extractor == nullptr
|
||
|
? "nullptr"
|
||
|
: memtable_insert_with_hint_prefix_extractor->Name());
|
||
|
ROCKS_LOG_HEADER(log, " Options.num_levels: %d", num_levels);
|
||
|
ROCKS_LOG_HEADER(log, " Options.min_write_buffer_number_to_merge: %d",
|
||
|
min_write_buffer_number_to_merge);
|
||
|
ROCKS_LOG_HEADER(log, " Options.max_write_buffer_number_to_maintain: %d",
|
||
|
max_write_buffer_number_to_maintain);
|
||
|
ROCKS_LOG_HEADER(log, " Options.compression_opts.window_bits: %d",
|
||
|
compression_opts.window_bits);
|
||
|
ROCKS_LOG_HEADER(log, " Options.compression_opts.level: %d",
|
||
|
compression_opts.level);
|
||
|
ROCKS_LOG_HEADER(log, " Options.compression_opts.strategy: %d",
|
||
|
compression_opts.strategy);
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log,
|
||
9 years ago
|
" Options.compression_opts.max_dict_bytes: %" ROCKSDB_PRIszt,
|
||
|
compression_opts.max_dict_bytes);
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, " Options.level0_file_num_compaction_trigger: %d",
|
||
|
level0_file_num_compaction_trigger);
|
||
|
ROCKS_LOG_HEADER(log, " Options.level0_slowdown_writes_trigger: %d",
|
||
|
level0_slowdown_writes_trigger);
|
||
|
ROCKS_LOG_HEADER(log, " Options.level0_stop_writes_trigger: %d",
|
||
|
level0_stop_writes_trigger);
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.target_file_size_base: %" PRIu64,
|
||
12 years ago
|
target_file_size_base);
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, " Options.target_file_size_multiplier: %d",
|
||
|
target_file_size_multiplier);
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.max_bytes_for_level_base: %" PRIu64,
|
||
10 years ago
|
max_bytes_for_level_base);
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, "Options.level_compaction_dynamic_level_bytes: %d",
|
||
|
level_compaction_dynamic_level_bytes);
|
||
|
ROCKS_LOG_HEADER(log, " Options.max_bytes_for_level_multiplier: %f",
|
||
|
max_bytes_for_level_multiplier);
|
||
10 years ago
|
for (size_t i = 0; i < max_bytes_for_level_multiplier_additional.size();
|
||
|
i++) {
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, "Options.max_bytes_for_level_multiplier_addtl[%" ROCKSDB_PRIszt
|
||
|
"]: %d",
|
||
|
i, max_bytes_for_level_multiplier_additional[i]);
|
||
12 years ago
|
}
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.max_sequential_skip_in_iterations: %" PRIu64,
|
||
10 years ago
|
max_sequential_skip_in_iterations);
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.max_compaction_bytes: %" PRIu64,
|
||
|
max_compaction_bytes);
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log,
|
||
|
" Options.arena_block_size: %" ROCKSDB_PRIszt,
|
||
|
arena_block_size);
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.soft_pending_compaction_bytes_limit: %" PRIu64,
|
||
|
soft_pending_compaction_bytes_limit);
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.hard_pending_compaction_bytes_limit: %" PRIu64,
|
||
|
hard_pending_compaction_bytes_limit);
|
||
|
ROCKS_LOG_HEADER(log, " Options.rate_limit_delay_max_milliseconds: %u",
|
||
|
rate_limit_delay_max_milliseconds);
|
||
|
ROCKS_LOG_HEADER(log, " Options.disable_auto_compactions: %d",
|
||
|
disable_auto_compactions);
|
||
8 years ago
|
|
||
|
const auto& it_compaction_style =
|
||
|
compaction_style_to_string.find(compaction_style);
|
||
|
std::string str_compaction_style;
|
||
|
if (it_compaction_style == compaction_style_to_string.end()) {
|
||
|
assert(false);
|
||
|
str_compaction_style = "unknown_" + std::to_string(compaction_style);
|
||
|
} else {
|
||
|
str_compaction_style = it_compaction_style->second;
|
||
|
}
|
||
8 years ago
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.compaction_style: %s",
|
||
|
str_compaction_style.c_str());
|
||
8 years ago
|
|
||
|
const auto& it_compaction_pri =
|
||
|
compaction_pri_to_string.find(compaction_pri);
|
||
|
std::string str_compaction_pri;
|
||
|
if (it_compaction_pri == compaction_pri_to_string.end()) {
|
||
|
assert(false);
|
||
|
str_compaction_pri = "unknown_" + std::to_string(compaction_pri);
|
||
|
} else {
|
||
|
str_compaction_pri = it_compaction_pri->second;
|
||
|
}
|
||
8 years ago
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.compaction_pri: %s",
|
||
|
str_compaction_pri.c_str());
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.compaction_options_universal.size_ratio: %u",
|
||
|
compaction_options_universal.size_ratio);
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
"Options.compaction_options_universal.min_merge_width: %u",
|
||
|
compaction_options_universal.min_merge_width);
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
"Options.compaction_options_universal.max_merge_width: %u",
|
||
|
compaction_options_universal.max_merge_width);
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log,
|
||
|
"Options.compaction_options_universal."
|
||
|
"max_size_amplification_percent: %u",
|
||
11 years ago
|
compaction_options_universal.max_size_amplification_percent);
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log,
|
||
10 years ago
|
"Options.compaction_options_universal.compression_size_percent: %d",
|
||
11 years ago
|
compaction_options_universal.compression_size_percent);
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, "Options.compaction_options_fifo.max_table_files_size: %" PRIu64,
|
||
11 years ago
|
compaction_options_fifo.max_table_files_size);
|
||
11 years ago
|
std::string collector_names;
|
||
11 years ago
|
for (const auto& collector_factory : table_properties_collector_factories) {
|
||
|
collector_names.append(collector_factory->Name());
|
||
11 years ago
|
collector_names.append("; ");
|
||
|
}
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.table_properties_collectors: %s",
|
||
11 years ago
|
collector_names.c_str());
|
||
8 years ago
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.inplace_update_support: %d",
|
||
|
inplace_update_support);
|
||
|
ROCKS_LOG_HEADER(
|
||
|
log,
|
||
|
" Options.inplace_update_num_locks: %" ROCKSDB_PRIszt,
|
||
|
inplace_update_num_locks);
|
||
11 years ago
|
// TODO: easier config for bloom (maybe based on avg key/value size)
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log, " Options.memtable_prefix_bloom_size_ratio: %f",
|
||
|
memtable_prefix_bloom_size_ratio);
|
||
10 years ago
|
|
||
8 years ago
|
ROCKS_LOG_HEADER(log, " Options.memtable_huge_page_size: %" ROCKSDB_PRIszt,
|
||
|
memtable_huge_page_size);
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.bloom_locality: %d",
|
||
|
bloom_locality);
|
||
10 years ago
|
|
||
8 years ago
|
ROCKS_LOG_HEADER(
|
||
|
log,
|
||
|
" Options.max_successive_merges: %" ROCKSDB_PRIszt,
|
||
|
max_successive_merges);
|
||
|
ROCKS_LOG_HEADER(log,
|
||
|
" Options.optimize_filters_for_hits: %d",
|
||
|
optimize_filters_for_hits);
|
||
|
ROCKS_LOG_HEADER(log, " Options.paranoid_file_checks: %d",
|
||
|
paranoid_file_checks);
|
||
|
ROCKS_LOG_HEADER(log, " Options.force_consistency_checks: %d",
|
||
|
force_consistency_checks);
|
||
|
ROCKS_LOG_HEADER(log, " Options.report_bg_io_stats: %d",
|
||
|
report_bg_io_stats);
|
||
11 years ago
|
} // ColumnFamilyOptions::Dump
|
||
|
|
||
|
void Options::Dump(Logger* log) const {
|
||
|
DBOptions::Dump(log);
|
||
|
ColumnFamilyOptions::Dump(log);
|
||
12 years ago
|
} // Options::Dump
|
||
|
|
||
10 years ago
|
void Options::DumpCFOptions(Logger* log) const {
|
||
|
ColumnFamilyOptions::Dump(log);
|
||
|
} // Options::DumpCFOptions
|
||
|
|
||
12 years ago
|
//
|
||
|
// The goal of this method is to create a configuration that
|
||
|
// allows an application to write all files into L0 and
|
||
|
// then do a single compaction to output all files into L1.
|
||
12 years ago
|
Options*
|
||
|
Options::PrepareForBulkLoad()
|
||
|
{
|
||
12 years ago
|
// never slowdown ingest.
|
||
12 years ago
|
level0_file_num_compaction_trigger = (1<<30);
|
||
|
level0_slowdown_writes_trigger = (1<<30);
|
||
|
level0_stop_writes_trigger = (1<<30);
|
||
9 years ago
|
soft_pending_compaction_bytes_limit = 0;
|
||
|
hard_pending_compaction_bytes_limit = 0;
|
||
12 years ago
|
|
||
|
// no auto compactions please. The application should issue a
|
||
|
// manual compaction after all data is loaded into L0.
|
||
12 years ago
|
disable_auto_compactions = true;
|
||
12 years ago
|
// A manual compaction run should pick all files in L0 in
|
||
|
// a single compaction run.
|
||
9 years ago
|
max_compaction_bytes = (static_cast<uint64_t>(1) << 60);
|
||
12 years ago
|
|
||
12 years ago
|
// It is better to have only 2 levels, otherwise a manual
|
||
|
// compaction would compact at every possible level, thereby
|
||
|
// increasing the total time needed for compactions.
|
||
|
num_levels = 2;
|
||
|
|
||
10 years ago
|
// Need to allow more write buffers to allow more parallism
|
||
|
// of flushes.
|
||
|
max_write_buffer_number = 6;
|
||
|
min_write_buffer_number_to_merge = 1;
|
||
|
|
||
|
// When compaction is disabled, more parallel flush threads can
|
||
|
// help with write throughput.
|
||
|
max_background_flushes = 4;
|
||
|
|
||
12 years ago
|
// Prevent a memtable flush to automatically promote files
|
||
|
// to L1. This is helpful so that all files that are
|
||
|
// input to the manual compaction are all at L0.
|
||
|
max_background_compactions = 2;
|
||
9 years ago
|
base_background_compactions = 2;
|
||
12 years ago
|
|
||
|
// The compaction would create large files in L1.
|
||
|
target_file_size_base = 256 * 1024 * 1024;
|
||
12 years ago
|
return this;
|
||
|
}
|
||
|
|
||
9 years ago
|
Options* Options::OptimizeForSmallDb() {
|
||
|
ColumnFamilyOptions::OptimizeForSmallDb();
|
||
|
DBOptions::OptimizeForSmallDb();
|
||
|
return this;
|
||
|
}
|
||
|
|
||
9 years ago
|
Options* Options::OldDefaults(int rocksdb_major_version,
|
||
|
int rocksdb_minor_version) {
|
||
|
ColumnFamilyOptions::OldDefaults(rocksdb_major_version,
|
||
|
rocksdb_minor_version);
|
||
|
DBOptions::OldDefaults(rocksdb_major_version, rocksdb_minor_version);
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
DBOptions* DBOptions::OldDefaults(int rocksdb_major_version,
|
||
|
int rocksdb_minor_version) {
|
||
9 years ago
|
if (rocksdb_major_version < 4 ||
|
||
|
(rocksdb_major_version == 4 && rocksdb_minor_version < 7)) {
|
||
|
max_file_opening_threads = 1;
|
||
|
table_cache_numshardbits = 4;
|
||
|
}
|
||
8 years ago
|
if (rocksdb_major_version < 5 ||
|
||
|
(rocksdb_major_version == 5 && rocksdb_minor_version < 2)) {
|
||
|
delayed_write_rate = 2 * 1024U * 1024U;
|
||
|
}
|
||
|
|
||
9 years ago
|
max_open_files = 5000;
|
||
|
base_background_compactions = -1;
|
||
|
wal_recovery_mode = WALRecoveryMode::kTolerateCorruptedTailRecords;
|
||
9 years ago
|
return this;
|
||
|
}
|
||
|
|
||
|
ColumnFamilyOptions* ColumnFamilyOptions::OldDefaults(
|
||
|
int rocksdb_major_version, int rocksdb_minor_version) {
|
||
9 years ago
|
if (rocksdb_major_version < 4 ||
|
||
|
(rocksdb_major_version == 4 && rocksdb_minor_version < 7)) {
|
||
|
write_buffer_size = 4 << 20;
|
||
|
target_file_size_base = 2 * 1048576;
|
||
|
max_bytes_for_level_base = 10 * 1048576;
|
||
|
soft_pending_compaction_bytes_limit = 0;
|
||
|
hard_pending_compaction_bytes_limit = 0;
|
||
|
}
|
||
8 years ago
|
if (rocksdb_major_version < 5) {
|
||
|
level0_stop_writes_trigger = 24;
|
||
8 years ago
|
} else if (rocksdb_major_version == 5 && rocksdb_minor_version < 2) {
|
||
|
level0_stop_writes_trigger = 30;
|
||
8 years ago
|
}
|
||
9 years ago
|
compaction_pri = CompactionPri::kByCompensatedSize;
|
||
|
|
||
9 years ago
|
return this;
|
||
|
}
|
||
|
|
||
11 years ago
|
// Optimization functions
|
||
9 years ago
|
DBOptions* DBOptions::OptimizeForSmallDb() {
|
||
|
max_file_opening_threads = 1;
|
||
|
max_open_files = 5000;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
9 years ago
|
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeForSmallDb() {
|
||
|
write_buffer_size = 2 << 20;
|
||
|
target_file_size_base = 2 * 1048576;
|
||
|
max_bytes_for_level_base = 10 * 1048576;
|
||
|
soft_pending_compaction_bytes_limit = 256 * 1048576;
|
||
|
hard_pending_compaction_bytes_limit = 1073741824ul;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
#ifndef ROCKSDB_LITE
|
||
10 years ago
|
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeForPointLookup(
|
||
|
uint64_t block_cache_size_mb) {
|
||
11 years ago
|
prefix_extractor.reset(NewNoopTransform());
|
||
|
BlockBasedTableOptions block_based_options;
|
||
10 years ago
|
block_based_options.index_type = BlockBasedTableOptions::kHashSearch;
|
||
|
block_based_options.filter_policy.reset(NewBloomFilterPolicy(10));
|
||
|
block_based_options.block_cache =
|
||
10 years ago
|
NewLRUCache(static_cast<size_t>(block_cache_size_mb * 1024 * 1024));
|
||
11 years ago
|
table_factory.reset(new BlockBasedTableFactory(block_based_options));
|
||
8 years ago
|
memtable_prefix_bloom_size_ratio = 0.02;
|
||
11 years ago
|
return this;
|
||
|
}
|
||
|
|
||
|
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeLevelStyleCompaction(
|
||
|
uint64_t memtable_memory_budget) {
|
||
10 years ago
|
write_buffer_size = static_cast<size_t>(memtable_memory_budget / 4);
|
||
11 years ago
|
// merge two memtables when flushing to L0
|
||
|
min_write_buffer_number_to_merge = 2;
|
||
|
// this means we'll use 50% extra memory in the worst case, but will reduce
|
||
|
// write stalls.
|
||
|
max_write_buffer_number = 6;
|
||
|
// start flushing L0->L1 as soon as possible. each file on level0 is
|
||
|
// (memtable_memory_budget / 2). This will flush level 0 when it's bigger than
|
||
|
// memtable_memory_budget.
|
||
|
level0_file_num_compaction_trigger = 2;
|
||
|
// doesn't really matter much, but we don't want to create too many files
|
||
|
target_file_size_base = memtable_memory_budget / 8;
|
||
|
// make Level1 size equal to Level0 size, so that L0->L1 compactions are fast
|
||
|
max_bytes_for_level_base = memtable_memory_budget;
|
||
|
|
||
|
// level style compaction
|
||
|
compaction_style = kCompactionStyleLevel;
|
||
|
|
||
|
// only compress levels >= 2
|
||
|
compression_per_level.resize(num_levels);
|
||
|
for (int i = 0; i < num_levels; ++i) {
|
||
|
if (i < 2) {
|
||
|
compression_per_level[i] = kNoCompression;
|
||
|
} else {
|
||
|
compression_per_level[i] = kSnappyCompression;
|
||
|
}
|
||
|
}
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeUniversalStyleCompaction(
|
||
|
uint64_t memtable_memory_budget) {
|
||
10 years ago
|
write_buffer_size = static_cast<size_t>(memtable_memory_budget / 4);
|
||
11 years ago
|
// merge two memtables when flushing to L0
|
||
|
min_write_buffer_number_to_merge = 2;
|
||
|
// this means we'll use 50% extra memory in the worst case, but will reduce
|
||
|
// write stalls.
|
||
|
max_write_buffer_number = 6;
|
||
|
// universal style compaction
|
||
|
compaction_style = kCompactionStyleUniversal;
|
||
|
compaction_options_universal.compression_size_percent = 80;
|
||
|
return this;
|
||
|
}
|
||
|
|
||
|
DBOptions* DBOptions::IncreaseParallelism(int total_threads) {
|
||
|
max_background_compactions = total_threads - 1;
|
||
|
max_background_flushes = 1;
|
||
|
env->SetBackgroundThreads(total_threads, Env::LOW);
|
||
|
env->SetBackgroundThreads(1, Env::HIGH);
|
||
|
return this;
|
||
|
}
|
||
10 years ago
|
|
||
10 years ago
|
#endif // !ROCKSDB_LITE
|
||
|
|
||
10 years ago
|
ReadOptions::ReadOptions()
|
||
|
: verify_checksums(true),
|
||
|
fill_cache(true),
|
||
|
snapshot(nullptr),
|
||
|
iterate_upper_bound(nullptr),
|
||
|
read_tier(kReadAllTier),
|
||
|
tailing(false),
|
||
|
managed(false),
|
||
9 years ago
|
total_order_seek(false),
|
||
9 years ago
|
prefix_same_as_start(false),
|
||
9 years ago
|
pin_data(false),
|
||
9 years ago
|
background_purge_on_iterator_cleanup(false),
|
||
8 years ago
|
readahead_size(0),
|
||
8 years ago
|
ignore_range_deletions(false),
|
||
|
max_skippable_internal_keys(0) {}
|
||
10 years ago
|
|
||
|
ReadOptions::ReadOptions(bool cksum, bool cache)
|
||
|
: verify_checksums(cksum),
|
||
|
fill_cache(cache),
|
||
|
snapshot(nullptr),
|
||
|
iterate_upper_bound(nullptr),
|
||
|
read_tier(kReadAllTier),
|
||
|
tailing(false),
|
||
|
managed(false),
|
||
9 years ago
|
total_order_seek(false),
|
||
9 years ago
|
prefix_same_as_start(false),
|
||
9 years ago
|
pin_data(false),
|
||
9 years ago
|
background_purge_on_iterator_cleanup(false),
|
||
8 years ago
|
readahead_size(0),
|
||
8 years ago
|
ignore_range_deletions(false),
|
||
|
max_skippable_internal_keys(0) {}
|
||
10 years ago
|
|
||
11 years ago
|
} // namespace rocksdb
|