2016-02-10 00:12:00 +01:00
|
|
|
// Copyright (c) 2011-present, Facebook, Inc. All rights reserved.
|
2017-07-16 01:03:42 +02:00
|
|
|
// This source code is licensed under both the GPLv2 (found in the
|
|
|
|
// COPYING file in the root directory) and Apache 2.0 License
|
|
|
|
// (found in the LICENSE.Apache file in the root directory).
|
2013-10-16 23:59:46 +02:00
|
|
|
//
|
2011-03-18 23:37:00 +01:00
|
|
|
// 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.
|
|
|
|
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/options.h"
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2014-09-05 08:14:37 +02:00
|
|
|
#ifndef __STDC_FORMAT_MACROS
|
2014-04-30 20:33:40 +02:00
|
|
|
#define __STDC_FORMAT_MACROS
|
2014-09-05 08:14:37 +02:00
|
|
|
#endif
|
|
|
|
|
2014-04-30 20:33:40 +02:00
|
|
|
#include <inttypes.h>
|
2013-01-11 02:18:50 +01:00
|
|
|
#include <limits>
|
|
|
|
|
2017-04-06 04:02:00 +02:00
|
|
|
#include "monitoring/statistics.h"
|
|
|
|
#include "options/db_options.h"
|
|
|
|
#include "options/options_helper.h"
|
2013-08-23 17:38:13 +02:00
|
|
|
#include "rocksdb/cache.h"
|
|
|
|
#include "rocksdb/compaction_filter.h"
|
|
|
|
#include "rocksdb/comparator.h"
|
|
|
|
#include "rocksdb/env.h"
|
2014-01-25 01:15:05 +01:00
|
|
|
#include "rocksdb/memtablerep.h"
|
2014-01-28 06:58:46 +01:00
|
|
|
#include "rocksdb/merge_operator.h"
|
2014-01-25 01:15:05 +01:00
|
|
|
#include "rocksdb/slice.h"
|
|
|
|
#include "rocksdb/slice_transform.h"
|
2017-02-01 02:30:20 +01:00
|
|
|
#include "rocksdb/sst_file_manager.h"
|
2014-01-28 06:58:46 +01:00
|
|
|
#include "rocksdb/table.h"
|
2014-01-25 01:15:05 +01:00
|
|
|
#include "rocksdb/table_properties.h"
|
2015-10-13 02:03:03 +02:00
|
|
|
#include "rocksdb/wal_filter.h"
|
2013-10-29 01:54:09 +01:00
|
|
|
#include "table/block_based_table_factory.h"
|
2015-04-06 21:50:44 +02:00
|
|
|
#include "util/compression.h"
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
namespace rocksdb {
|
2011-03-18 23:37:00 +01:00
|
|
|
|
2017-02-28 02:36:06 +01:00
|
|
|
AdvancedColumnFamilyOptions::AdvancedColumnFamilyOptions() {
|
[RocksDB] [Column Family] Interface proposal
Summary:
<This diff is for Column Family branch>
Sharing some of the work I've done so far. This diff compiles and passes the tests.
The biggest change is in options.h - I broke down Options into two parts - DBOptions and ColumnFamilyOptions. DBOptions is DB-specific (env, create_if_missing, block_cache, etc.) and ColumnFamilyOptions is column family-specific (all compaction options, compresion options, etc.). Note that this does not break backwards compatibility at all.
Further, I created DBWithColumnFamily which inherits DB interface and adds new functions with column family support. Clients can transparently switch to DBWithColumnFamily and it will not break their backwards compatibility.
There are few methods worth checking out: ListColumnFamilies(), MultiNewIterator(), MultiGet() and GetSnapshot(). [GetSnapshot() returns the snapshot across all column families for now - I think that's what we agreed on]
Finally, I made small changes to WriteBatch so we are able to atomically insert data across column families.
Please provide feedback.
Test Plan: make check works, the code is backward compatible
Reviewers: dhruba, haobo, sdong, kailiu, emayanke
CC: leveldb
Differential Revision: https://reviews.facebook.net/D14445
2013-12-03 20:14:09 +01:00
|
|
|
assert(memtable_factory.get() != nullptr);
|
|
|
|
}
|
|
|
|
|
2017-02-28 02:36:06 +01:00
|
|
|
AdvancedColumnFamilyOptions::AdvancedColumnFamilyOptions(const Options& options)
|
|
|
|
: max_write_buffer_number(options.max_write_buffer_number),
|
2014-01-06 22:31:06 +01:00
|
|
|
min_write_buffer_number_to_merge(
|
|
|
|
options.min_write_buffer_number_to_merge),
|
Support saving history in memtable_list
Summary:
For transactions, we are using the memtables to validate that there are no write conflicts. But after flushing, we don't have any memtables, and transactions could fail to commit. So we want to someone keep around some extra history to use for conflict checking. In addition, we want to provide a way to increase the size of this history if too many transactions fail to commit.
After chatting with people, it seems like everyone prefers just using Memtables to store this history (instead of a separate history structure). It seems like the best place for this is abstracted inside the memtable_list. I decide to create a separate list in MemtableListVersion as using the same list complicated the flush/installalflushresults logic too much.
This diff adds a new parameter to control how much memtable history to keep around after flushing. However, it sounds like people aren't too fond of adding new parameters. So I am making the default size of flushed+not-flushed memtables be set to max_write_buffers. This should not change the maximum amount of memory used, but make it more likely we're using closer the the limit. (We are now postponing deleting flushed memtables until the max_write_buffer limit is reached). So while we might use more memory on average, we are still obeying the limit set (and you could argue it's better to go ahead and use up memory now instead of waiting for a write stall to happen to test this limit).
However, if people are opposed to this default behavior, we can easily set it to 0 and require this parameter be set in order to use transactions.
Test Plan: Added a xfunc test to play around with setting different values of this parameter in all tests. Added testing in memtablelist_test and planning on adding more testing here.
Reviewers: sdong, rven, igor
Reviewed By: igor
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D37443
2015-05-29 01:34:24 +02:00
|
|
|
max_write_buffer_number_to_maintain(
|
|
|
|
options.max_write_buffer_number_to_maintain),
|
2017-02-28 02:36:06 +01:00
|
|
|
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),
|
2019-02-19 21:12:25 +01:00
|
|
|
memtable_whole_key_filtering(options.memtable_whole_key_filtering),
|
2017-02-28 02:36:06 +01:00
|
|
|
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),
|
2014-01-06 22:31:06 +01:00
|
|
|
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),
|
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
|
|
|
level_compaction_dynamic_level_bytes(
|
|
|
|
options.level_compaction_dynamic_level_bytes),
|
2014-01-06 22:31:06 +01:00
|
|
|
max_bytes_for_level_multiplier(options.max_bytes_for_level_multiplier),
|
|
|
|
max_bytes_for_level_multiplier_additional(
|
|
|
|
options.max_bytes_for_level_multiplier_additional),
|
2016-06-17 01:02:52 +02:00
|
|
|
max_compaction_bytes(options.max_compaction_bytes),
|
2015-11-19 03:10:20 +01:00
|
|
|
soft_pending_compaction_bytes_limit(
|
|
|
|
options.soft_pending_compaction_bytes_limit),
|
2015-09-11 23:31:23 +02:00
|
|
|
hard_pending_compaction_bytes_limit(
|
|
|
|
options.hard_pending_compaction_bytes_limit),
|
2014-01-06 22:31:06 +01:00
|
|
|
compaction_style(options.compaction_style),
|
2015-09-22 02:16:31 +02:00
|
|
|
compaction_pri(options.compaction_pri),
|
2014-01-06 22:31:06 +01:00
|
|
|
compaction_options_universal(options.compaction_options_universal),
|
2014-05-21 20:43:35 +02:00
|
|
|
compaction_options_fifo(options.compaction_options_fifo),
|
2014-01-06 22:31:06 +01:00
|
|
|
max_sequential_skip_in_iterations(
|
|
|
|
options.max_sequential_skip_in_iterations),
|
|
|
|
memtable_factory(options.memtable_factory),
|
TablePropertiesCollectorFactory
Summary:
This diff addresses task #4296714 and rethinks how users provide us with TablePropertiesCollectors as part of Options.
Here's description of task #4296714:
I'm debugging #4295529 and noticed that our count of user properties kDeletedKeys is wrong. We're sharing one single InternalKeyPropertiesCollector with all Table Builders. In LOG Files, we're outputting number of kDeletedKeys as connected with a single table, while it's actually the total count of deleted keys since creation of the DB.
For example, this table has 3155 entries and 1391828 deleted keys.
The problem with current approach that we call methods on a single TablePropertiesCollector for all the tables we create. Even worse, we could do it from multiple threads at the same time and TablePropertiesCollector has no way of knowing which table we're calling it for.
Good part: Looks like nobody inside Facebook is using Options::table_properties_collectors. This means we should be able to painfully change the API.
In this change, I introduce TablePropertiesCollectorFactory. For every table we create, we call `CreateTablePropertiesCollector`, which creates a TablePropertiesCollector for a single table. We then use it sequentially from a single thread, which means it doesn't have to be thread-safe.
Test Plan:
Added a test in table_properties_collector_test that fails on master (build two tables, assert that kDeletedKeys count is correct for the second one).
Also, all other tests
Reviewers: sdong, dhruba, haobo, kailiu
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D18579
2014-05-13 21:30:55 +02:00
|
|
|
table_properties_collector_factories(
|
|
|
|
options.table_properties_collector_factories),
|
2014-03-25 19:09:40 +01:00
|
|
|
max_successive_merges(options.max_successive_merges),
|
2015-04-18 00:26:50 +02:00
|
|
|
optimize_filters_for_hits(options.optimize_filters_for_hits),
|
Add options.compaction_measure_io_stats to print write I/O stats in compactions
Summary:
Add options.compaction_measure_io_stats to print out / pass to listener accumulated time spent on write calls. Example outputs in info logs:
2015/08/12-16:27:59.463944 7fd428bff700 (Original Log Time 2015/08/12-16:27:59.463922) EVENT_LOG_v1 {"time_micros": 1439422079463897, "job": 6, "event": "compaction_finished", "output_level": 1, "num_output_files": 4, "total_output_size": 6900525, "num_input_records": 111483, "num_output_records": 106877, "file_write_nanos": 15663206, "file_range_sync_nanos": 649588, "file_fsync_nanos": 349614797, "file_prepare_write_nanos": 1505812, "lsm_state": [2, 4, 0, 0, 0, 0, 0]}
Add two more counters in iostats_context.
Also add a parameter of db_bench.
Test Plan: Add a unit test. Also manually verify LOG outputs in db_bench
Subscribers: leveldb, dhruba
Differential Revision: https://reviews.facebook.net/D44115
2015-08-13 02:24:45 +02:00
|
|
|
paranoid_file_checks(options.paranoid_file_checks),
|
2016-10-08 02:21:45 +02:00
|
|
|
force_consistency_checks(options.force_consistency_checks),
|
2018-04-03 06:57:28 +02:00
|
|
|
report_bg_io_stats(options.report_bg_io_stats),
|
2019-03-18 20:07:35 +01:00
|
|
|
ttl(options.ttl),
|
|
|
|
sample_for_compression(options.sample_for_compression) {
|
2014-01-06 22:31:06 +01:00
|
|
|
assert(memtable_factory.get() != nullptr);
|
2014-06-25 23:31:30 +02:00
|
|
|
if (max_bytes_for_level_multiplier_additional.size() <
|
|
|
|
static_cast<unsigned int>(num_levels)) {
|
2014-06-25 22:11:12 +02:00
|
|
|
max_bytes_for_level_multiplier_additional.resize(num_levels, 1);
|
|
|
|
}
|
2014-01-06 22:31:06 +01:00
|
|
|
}
|
|
|
|
|
2017-02-28 02:36:06 +01:00
|
|
|
ColumnFamilyOptions::ColumnFamilyOptions()
|
|
|
|
: compression(Snappy_Supported() ? kSnappyCompression : kNoCompression),
|
|
|
|
table_factory(
|
|
|
|
std::shared_ptr<TableFactory>(new BlockBasedTableFactory())) {}
|
|
|
|
|
|
|
|
ColumnFamilyOptions::ColumnFamilyOptions(const Options& options)
|
2017-09-16 02:09:48 +02:00
|
|
|
: ColumnFamilyOptions(*static_cast<const ColumnFamilyOptions*>(&options)) {}
|
2017-02-28 02:36:06 +01:00
|
|
|
|
2017-02-01 02:57:56 +01:00
|
|
|
DBOptions::DBOptions() {}
|
2014-01-06 22:31:06 +01:00
|
|
|
DBOptions::DBOptions(const Options& options)
|
2017-09-16 02:09:48 +02:00
|
|
|
: DBOptions(*static_cast<const DBOptions*>(&options)) {}
|
2014-01-06 22:31:06 +01:00
|
|
|
|
2014-02-07 06:39:20 +01:00
|
|
|
void DBOptions::Dump(Logger* log) const {
|
2017-02-01 02:30:20 +01:00
|
|
|
ImmutableDBOptions(*this).Dump(log);
|
|
|
|
MutableDBOptions(*this).Dump(log);
|
2014-02-07 06:39:20 +01:00
|
|
|
} // DBOptions::Dump
|
|
|
|
|
|
|
|
void ColumnFamilyOptions::Dump(Logger* log) const {
|
2017-03-16 03:22:52 +01:00
|
|
|
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",
|
2015-06-09 01:34:26 +02:00
|
|
|
compaction_filter_factory ? compaction_filter_factory->Name() : "None");
|
2017-03-16 03:22:52 +01:00
|
|
|
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());
|
|
|
|
}
|
2012-10-28 07:13:17 +01:00
|
|
|
} else {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.compression: %s",
|
|
|
|
CompressionTypeToString(compression).c_str());
|
2012-10-28 07:13:17 +01:00
|
|
|
}
|
2017-03-16 03:22:52 +01:00
|
|
|
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",
|
2013-08-14 18:06:10 +02:00
|
|
|
prefix_extractor == nullptr ? "nullptr" : prefix_extractor->Name());
|
2017-03-16 03:22:52 +01:00
|
|
|
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);
|
2018-06-28 02:34:07 +02:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.bottommost_compression_opts.window_bits: %d",
|
|
|
|
bottommost_compression_opts.window_bits);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.bottommost_compression_opts.level: %d",
|
|
|
|
bottommost_compression_opts.level);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.bottommost_compression_opts.strategy: %d",
|
|
|
|
bottommost_compression_opts.strategy);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log,
|
|
|
|
" Options.bottommost_compression_opts.max_dict_bytes: "
|
2019-04-04 21:05:42 +02:00
|
|
|
"%" PRIu32,
|
2018-06-28 02:34:07 +02:00
|
|
|
bottommost_compression_opts.max_dict_bytes);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log,
|
|
|
|
" Options.bottommost_compression_opts.zstd_max_train_bytes: "
|
2019-04-04 21:05:42 +02:00
|
|
|
"%" PRIu32,
|
2018-06-28 02:34:07 +02:00
|
|
|
bottommost_compression_opts.zstd_max_train_bytes);
|
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.bottommost_compression_opts.enabled: %s",
|
|
|
|
bottommost_compression_opts.enabled ? "true" : "false");
|
2017-03-16 03:22:52 +01:00
|
|
|
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,
|
2019-04-04 21:05:42 +02:00
|
|
|
" Options.compression_opts.max_dict_bytes: %" PRIu32,
|
Shared dictionary compression using reference block
Summary:
This adds a new metablock containing a shared dictionary that is used
to compress all data blocks in the SST file. The size of the shared dictionary
is configurable in CompressionOptions and defaults to 0. It's currently only
used for zlib/lz4/lz4hc, but the block will be stored in the SST regardless of
the compression type if the user chooses a nonzero dictionary size.
During compaction, computes the dictionary by randomly sampling the first
output file in each subcompaction. It pre-computes the intervals to sample
by assuming the output file will have the maximum allowable length. In case
the file is smaller, some of the pre-computed sampling intervals can be beyond
end-of-file, in which case we skip over those samples and the dictionary will
be a bit smaller. After the dictionary is generated using the first file in a
subcompaction, it is loaded into the compression library before writing each
block in each subsequent file of that subcompaction.
On the read path, gets the dictionary from the metablock, if it exists. Then,
loads that dictionary into the compression library before reading each block.
Test Plan: new unit test
Reviewers: yhchiang, IslamAbdelRahman, cyan, sdong
Reviewed By: sdong
Subscribers: andrewkr, yoshinorim, kradhakrishnan, dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D52287
2016-04-28 02:36:03 +02:00
|
|
|
compression_opts.max_dict_bytes);
|
2018-03-22 23:10:53 +01:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.compression_opts.zstd_max_train_bytes: "
|
2019-04-04 21:05:42 +02:00
|
|
|
"%" PRIu32,
|
2018-03-22 23:10:53 +01:00
|
|
|
compression_opts.zstd_max_train_bytes);
|
2018-06-28 02:34:07 +02:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.compression_opts.enabled: %s",
|
|
|
|
compression_opts.enabled ? "true" : "false");
|
2017-03-16 03:22:52 +01:00
|
|
|
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,
|
2012-08-27 21:10:26 +02:00
|
|
|
target_file_size_base);
|
2017-03-16 03:22:52 +01:00
|
|
|
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,
|
2014-09-22 20:15:03 +02:00
|
|
|
max_bytes_for_level_base);
|
2017-03-16 03:22:52 +01:00
|
|
|
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);
|
2015-03-30 23:04:21 +02:00
|
|
|
for (size_t i = 0; i < max_bytes_for_level_multiplier_additional.size();
|
|
|
|
i++) {
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, "Options.max_bytes_for_level_multiplier_addtl[%" ROCKSDB_PRIszt
|
|
|
|
"]: %d",
|
|
|
|
i, max_bytes_for_level_multiplier_additional[i]);
|
2013-05-21 20:37:06 +02:00
|
|
|
}
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.max_sequential_skip_in_iterations: %" PRIu64,
|
2014-09-22 20:15:03 +02:00
|
|
|
max_sequential_skip_in_iterations);
|
2017-03-16 03:22:52 +01:00
|
|
|
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);
|
2017-02-07 19:35:15 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(log,
|
2017-05-10 00:44:48 +02:00
|
|
|
" Options.compaction_style: %s",
|
2017-03-16 03:22:52 +01:00
|
|
|
str_compaction_style.c_str());
|
2017-02-07 19:35:15 +01:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(log,
|
2017-05-10 00:44:48 +02:00
|
|
|
" Options.compaction_pri: %s",
|
2017-03-16 03:22:52 +01:00
|
|
|
str_compaction_pri.c_str());
|
|
|
|
ROCKS_LOG_HEADER(log,
|
2017-05-10 00:44:48 +02:00
|
|
|
"Options.compaction_options_universal.size_ratio: %u",
|
2017-03-16 03:22:52 +01:00
|
|
|
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",
|
2013-09-10 01:06:10 +02:00
|
|
|
compaction_options_universal.max_size_amplification_percent);
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log,
|
2014-09-19 22:09:25 +02:00
|
|
|
"Options.compaction_options_universal.compression_size_percent: %d",
|
2013-12-03 21:32:07 +01:00
|
|
|
compaction_options_universal.compression_size_percent);
|
2017-05-10 00:44:48 +02:00
|
|
|
const auto& it_compaction_stop_style = compaction_stop_style_to_string.find(
|
|
|
|
compaction_options_universal.stop_style);
|
|
|
|
std::string str_compaction_stop_style;
|
|
|
|
if (it_compaction_stop_style == compaction_stop_style_to_string.end()) {
|
|
|
|
assert(false);
|
|
|
|
str_compaction_stop_style =
|
|
|
|
"unknown_" + std::to_string(compaction_options_universal.stop_style);
|
|
|
|
} else {
|
|
|
|
str_compaction_stop_style = it_compaction_stop_style->second;
|
|
|
|
}
|
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
"Options.compaction_options_universal.stop_style: %s",
|
|
|
|
str_compaction_stop_style.c_str());
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, "Options.compaction_options_fifo.max_table_files_size: %" PRIu64,
|
2014-05-21 20:43:35 +02:00
|
|
|
compaction_options_fifo.max_table_files_size);
|
2017-05-05 03:14:29 +02:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
"Options.compaction_options_fifo.allow_compaction: %d",
|
|
|
|
compaction_options_fifo.allow_compaction);
|
2013-10-16 20:50:50 +02:00
|
|
|
std::string collector_names;
|
TablePropertiesCollectorFactory
Summary:
This diff addresses task #4296714 and rethinks how users provide us with TablePropertiesCollectors as part of Options.
Here's description of task #4296714:
I'm debugging #4295529 and noticed that our count of user properties kDeletedKeys is wrong. We're sharing one single InternalKeyPropertiesCollector with all Table Builders. In LOG Files, we're outputting number of kDeletedKeys as connected with a single table, while it's actually the total count of deleted keys since creation of the DB.
For example, this table has 3155 entries and 1391828 deleted keys.
The problem with current approach that we call methods on a single TablePropertiesCollector for all the tables we create. Even worse, we could do it from multiple threads at the same time and TablePropertiesCollector has no way of knowing which table we're calling it for.
Good part: Looks like nobody inside Facebook is using Options::table_properties_collectors. This means we should be able to painfully change the API.
In this change, I introduce TablePropertiesCollectorFactory. For every table we create, we call `CreateTablePropertiesCollector`, which creates a TablePropertiesCollector for a single table. We then use it sequentially from a single thread, which means it doesn't have to be thread-safe.
Test Plan:
Added a test in table_properties_collector_test that fails on master (build two tables, assert that kDeletedKeys count is correct for the second one).
Also, all other tests
Reviewers: sdong, dhruba, haobo, kailiu
Reviewed By: kailiu
CC: leveldb
Differential Revision: https://reviews.facebook.net/D18579
2014-05-13 21:30:55 +02:00
|
|
|
for (const auto& collector_factory : table_properties_collector_factories) {
|
|
|
|
collector_names.append(collector_factory->Name());
|
2013-10-16 20:50:50 +02:00
|
|
|
collector_names.append("; ");
|
|
|
|
}
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.table_properties_collectors: %s",
|
2013-10-16 20:50:50 +02:00
|
|
|
collector_names.c_str());
|
2017-03-16 03:22:52 +01:00
|
|
|
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);
|
2013-11-27 23:27:02 +01:00
|
|
|
// TODO: easier config for bloom (maybe based on avg key/value size)
|
2017-03-16 03:22:52 +01:00
|
|
|
ROCKS_LOG_HEADER(
|
|
|
|
log, " Options.memtable_prefix_bloom_size_ratio: %f",
|
|
|
|
memtable_prefix_bloom_size_ratio);
|
2019-02-19 21:12:25 +01:00
|
|
|
ROCKS_LOG_HEADER(log,
|
|
|
|
" Options.memtable_whole_key_filtering: %d",
|
|
|
|
memtable_whole_key_filtering);
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2017-03-16 03:22:52 +01:00
|
|
|
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);
|
2015-07-02 01:13:49 +02:00
|
|
|
|
2017-03-16 03:22:52 +01:00
|
|
|
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);
|
2019-04-04 21:05:42 +02:00
|
|
|
ROCKS_LOG_HEADER(log, " Options.ttl: %" PRIu64,
|
|
|
|
ttl);
|
2014-02-07 06:39:20 +01:00
|
|
|
} // ColumnFamilyOptions::Dump
|
|
|
|
|
|
|
|
void Options::Dump(Logger* log) const {
|
|
|
|
DBOptions::Dump(log);
|
|
|
|
ColumnFamilyOptions::Dump(log);
|
2012-08-22 20:43:53 +02:00
|
|
|
} // Options::Dump
|
|
|
|
|
2015-06-18 19:15:54 +02:00
|
|
|
void Options::DumpCFOptions(Logger* log) const {
|
|
|
|
ColumnFamilyOptions::Dump(log);
|
|
|
|
} // Options::DumpCFOptions
|
|
|
|
|
2013-03-08 18:19:24 +01:00
|
|
|
//
|
|
|
|
// 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.
|
2013-02-26 07:57:37 +01:00
|
|
|
Options*
|
|
|
|
Options::PrepareForBulkLoad()
|
|
|
|
{
|
2013-03-08 18:19:24 +01:00
|
|
|
// never slowdown ingest.
|
2013-02-26 07:57:37 +01:00
|
|
|
level0_file_num_compaction_trigger = (1<<30);
|
|
|
|
level0_slowdown_writes_trigger = (1<<30);
|
|
|
|
level0_stop_writes_trigger = (1<<30);
|
2016-06-16 23:05:34 +02:00
|
|
|
soft_pending_compaction_bytes_limit = 0;
|
|
|
|
hard_pending_compaction_bytes_limit = 0;
|
2013-03-08 18:19:24 +01:00
|
|
|
|
|
|
|
// no auto compactions please. The application should issue a
|
|
|
|
// manual compaction after all data is loaded into L0.
|
2013-02-26 07:57:37 +01:00
|
|
|
disable_auto_compactions = true;
|
2013-03-08 18:19:24 +01:00
|
|
|
// A manual compaction run should pick all files in L0 in
|
|
|
|
// a single compaction run.
|
2016-06-17 01:02:52 +02:00
|
|
|
max_compaction_bytes = (static_cast<uint64_t>(1) << 60);
|
2013-02-26 07:57:37 +01:00
|
|
|
|
2013-03-08 18:19:24 +01:00
|
|
|
// 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;
|
|
|
|
|
2015-02-02 20:09:21 +01:00
|
|
|
// 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;
|
|
|
|
|
2013-03-08 18:19:24 +01:00
|
|
|
// 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;
|
|
|
|
|
|
|
|
// The compaction would create large files in L1.
|
|
|
|
target_file_size_base = 256 * 1024 * 1024;
|
2013-02-26 07:57:37 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-05-06 01:50:32 +02:00
|
|
|
Options* Options::OptimizeForSmallDb() {
|
|
|
|
ColumnFamilyOptions::OptimizeForSmallDb();
|
|
|
|
DBOptions::OptimizeForSmallDb();
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-24 20:45:50 +01:00
|
|
|
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) {
|
2016-04-08 02:40:42 +02:00
|
|
|
if (rocksdb_major_version < 4 ||
|
|
|
|
(rocksdb_major_version == 4 && rocksdb_minor_version < 7)) {
|
|
|
|
max_file_opening_threads = 1;
|
|
|
|
table_cache_numshardbits = 4;
|
|
|
|
}
|
2017-02-02 05:25:01 +01:00
|
|
|
if (rocksdb_major_version < 5 ||
|
|
|
|
(rocksdb_major_version == 5 && rocksdb_minor_version < 2)) {
|
|
|
|
delayed_write_rate = 2 * 1024U * 1024U;
|
2017-05-24 18:52:08 +02:00
|
|
|
} else if (rocksdb_major_version < 5 ||
|
|
|
|
(rocksdb_major_version == 5 && rocksdb_minor_version < 6)) {
|
|
|
|
delayed_write_rate = 16 * 1024U * 1024U;
|
2017-02-02 05:25:01 +01:00
|
|
|
}
|
2016-04-08 02:40:42 +02:00
|
|
|
max_open_files = 5000;
|
|
|
|
wal_recovery_mode = WALRecoveryMode::kTolerateCorruptedTailRecords;
|
2016-03-24 20:45:50 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnFamilyOptions* ColumnFamilyOptions::OldDefaults(
|
|
|
|
int rocksdb_major_version, int rocksdb_minor_version) {
|
2019-01-24 01:44:02 +01:00
|
|
|
if (rocksdb_major_version < 5 ||
|
|
|
|
(rocksdb_major_version == 5 && rocksdb_minor_version <= 18)) {
|
|
|
|
compaction_pri = CompactionPri::kByCompensatedSize;
|
|
|
|
}
|
2016-04-08 02:40:42 +02:00
|
|
|
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;
|
|
|
|
}
|
2016-11-23 18:19:11 +01:00
|
|
|
if (rocksdb_major_version < 5) {
|
|
|
|
level0_stop_writes_trigger = 24;
|
2017-02-02 05:25:01 +01:00
|
|
|
} else if (rocksdb_major_version == 5 && rocksdb_minor_version < 2) {
|
|
|
|
level0_stop_writes_trigger = 30;
|
2016-11-23 18:19:11 +01:00
|
|
|
}
|
2016-04-08 02:40:42 +02:00
|
|
|
|
2016-03-24 20:45:50 +01:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2014-05-10 19:49:33 +02:00
|
|
|
// Optimization functions
|
2016-05-06 01:50:32 +02:00
|
|
|
DBOptions* DBOptions::OptimizeForSmallDb() {
|
|
|
|
max_file_opening_threads = 1;
|
|
|
|
max_open_files = 5000;
|
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
2016-03-24 20:45:50 +01:00
|
|
|
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
|
2014-08-26 23:15:00 +02:00
|
|
|
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeForPointLookup(
|
|
|
|
uint64_t block_cache_size_mb) {
|
2014-05-10 19:49:33 +02:00
|
|
|
prefix_extractor.reset(NewNoopTransform());
|
|
|
|
BlockBasedTableOptions block_based_options;
|
2014-08-26 23:15:00 +02:00
|
|
|
block_based_options.index_type = BlockBasedTableOptions::kHashSearch;
|
2018-07-28 00:35:41 +02:00
|
|
|
block_based_options.data_block_index_type =
|
2018-08-15 23:27:47 +02:00
|
|
|
BlockBasedTableOptions::kDataBlockBinaryAndHash;
|
|
|
|
block_based_options.data_block_hash_table_util_ratio = 0.75;
|
2014-08-26 23:15:00 +02:00
|
|
|
block_based_options.filter_policy.reset(NewBloomFilterPolicy(10));
|
|
|
|
block_based_options.block_cache =
|
2014-11-13 20:39:30 +01:00
|
|
|
NewLRUCache(static_cast<size_t>(block_cache_size_mb * 1024 * 1024));
|
2014-05-10 19:49:33 +02:00
|
|
|
table_factory.reset(new BlockBasedTableFactory(block_based_options));
|
2017-01-20 19:43:59 +01:00
|
|
|
memtable_prefix_bloom_size_ratio = 0.02;
|
2014-05-10 19:49:33 +02:00
|
|
|
return this;
|
|
|
|
}
|
|
|
|
|
|
|
|
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeLevelStyleCompaction(
|
|
|
|
uint64_t memtable_memory_budget) {
|
2014-11-13 20:39:30 +01:00
|
|
|
write_buffer_size = static_cast<size_t>(memtable_memory_budget / 4);
|
2014-05-10 19:49:33 +02:00
|
|
|
// 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) {
|
2014-11-13 20:39:30 +01:00
|
|
|
write_buffer_size = static_cast<size_t>(memtable_memory_budget / 4);
|
2014-05-10 19:49:33 +02:00
|
|
|
// 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) {
|
2017-12-04 10:53:49 +01:00
|
|
|
max_background_jobs = total_threads;
|
2014-05-10 19:49:33 +02:00
|
|
|
env->SetBackgroundThreads(total_threads, Env::LOW);
|
|
|
|
env->SetBackgroundThreads(1, Env::HIGH);
|
|
|
|
return this;
|
|
|
|
}
|
2015-02-18 20:49:31 +01:00
|
|
|
|
2015-04-10 06:05:09 +02:00
|
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
|
2015-02-18 20:49:31 +01:00
|
|
|
ReadOptions::ReadOptions()
|
2017-05-26 20:27:24 +02:00
|
|
|
: snapshot(nullptr),
|
2017-10-27 02:14:04 +02:00
|
|
|
iterate_lower_bound(nullptr),
|
2015-02-18 20:49:31 +01:00
|
|
|
iterate_upper_bound(nullptr),
|
2017-05-26 20:27:24 +02:00
|
|
|
readahead_size(0),
|
|
|
|
max_skippable_internal_keys(0),
|
2015-02-18 20:49:31 +01:00
|
|
|
read_tier(kReadAllTier),
|
2017-05-26 20:27:24 +02:00
|
|
|
verify_checksums(true),
|
|
|
|
fill_cache(true),
|
2015-02-18 20:49:31 +01:00
|
|
|
tailing(false),
|
|
|
|
managed(false),
|
2015-11-05 22:24:05 +01:00
|
|
|
total_order_seek(false),
|
2015-12-16 21:08:30 +01:00
|
|
|
prefix_same_as_start(false),
|
2016-05-05 00:25:58 +02:00
|
|
|
pin_data(false),
|
2016-06-22 03:41:23 +02:00
|
|
|
background_purge_on_iterator_cleanup(false),
|
Added support for differential snapshots
Summary:
The motivation for this PR is to add to RocksDB support for differential (incremental) snapshots, as snapshot of the DB changes between two points in time (one can think of it as diff between to sequence numbers, or the diff D which can be thought of as an SST file or just set of KVs that can be applied to sequence number S1 to get the database to the state at sequence number S2).
This feature would be useful for various distributed storages layers built on top of RocksDB, as it should help reduce resources (time and network bandwidth) needed to recover and rebuilt DB instances as replicas in the context of distributed storages.
From the API standpoint that would like client app requesting iterator between (start seqnum) and current DB state, and reading the "diff".
This is a very draft PR for initial review in the discussion on the approach, i'm going to rework some parts and keep updating the PR.
For now, what's done here according to initial discussions:
Preserving deletes:
- We want to be able to optionally preserve recent deletes for some defined period of time, so that if a delete came in recently and might need to be included in the next incremental snapshot it would't get dropped by a compaction. This is done by adding new param to Options (preserve deletes flag) and new variable to DB Impl where we keep track of the sequence number after which we don't want to drop tombstones, even if they are otherwise eligible for deletion.
- I also added a new API call for clients to be able to advance this cutoff seqnum after which we drop deletes; i assume it's more flexible to let clients control this, since otherwise we'd need to keep some kind of timestamp < -- > seqnum mapping inside the DB, which sounds messy and painful to support. Clients could make use of it by periodically calling GetLatestSequenceNumber(), noting the timestamp, doing some calculation and figuring out by how much we need to advance the cutoff seqnum.
- Compaction codepath in compaction_iterator.cc has been modified to avoid dropping tombstones with seqnum > cutoff seqnum.
Iterator changes:
- couple params added to ReadOptions, to optionally allow client to request internal keys instead of user keys (so that client can get the latest value of a key, be it delete marker or a put), as well as min timestamp and min seqnum.
TableCache changes:
- I modified table_cache code to be able to quickly exclude SST files from iterators heep if creation_time on the file is less then iter_start_ts as passed in ReadOptions. That would help a lot in some DB settings (like reading very recent data only or using FIFO compactions), but not so much for universal compaction with more or less long iterator time span.
What's left:
- Still looking at how to best plug that inside DBIter codepath. So far it seems that FindNextUserKeyInternal only parses values as UserKeys, and iter->key() call generally returns user key. Can we add new API to DBIter as internal_key(), and modify this internal method to optionally set saved_key_ to point to the full internal key? I don't need to store actual seqnum there, but I do need to store type.
Closes https://github.com/facebook/rocksdb/pull/2999
Differential Revision: D6175602
Pulled By: mikhail-antonov
fbshipit-source-id: c779a6696ee2d574d86c69cec866a3ae095aa900
2017-11-02 02:43:29 +01:00
|
|
|
ignore_range_deletions(false),
|
|
|
|
iter_start_seqnum(0) {}
|
2015-02-18 20:49:31 +01:00
|
|
|
|
|
|
|
ReadOptions::ReadOptions(bool cksum, bool cache)
|
2017-05-26 20:27:24 +02:00
|
|
|
: snapshot(nullptr),
|
2017-10-27 02:14:04 +02:00
|
|
|
iterate_lower_bound(nullptr),
|
2015-02-18 20:49:31 +01:00
|
|
|
iterate_upper_bound(nullptr),
|
2017-05-26 20:27:24 +02:00
|
|
|
readahead_size(0),
|
|
|
|
max_skippable_internal_keys(0),
|
2015-02-18 20:49:31 +01:00
|
|
|
read_tier(kReadAllTier),
|
2017-05-26 20:27:24 +02:00
|
|
|
verify_checksums(cksum),
|
|
|
|
fill_cache(cache),
|
2015-02-18 20:49:31 +01:00
|
|
|
tailing(false),
|
|
|
|
managed(false),
|
2015-11-05 22:24:05 +01:00
|
|
|
total_order_seek(false),
|
2015-12-16 21:08:30 +01:00
|
|
|
prefix_same_as_start(false),
|
2016-05-05 00:25:58 +02:00
|
|
|
pin_data(false),
|
2016-06-22 03:41:23 +02:00
|
|
|
background_purge_on_iterator_cleanup(false),
|
Added support for differential snapshots
Summary:
The motivation for this PR is to add to RocksDB support for differential (incremental) snapshots, as snapshot of the DB changes between two points in time (one can think of it as diff between to sequence numbers, or the diff D which can be thought of as an SST file or just set of KVs that can be applied to sequence number S1 to get the database to the state at sequence number S2).
This feature would be useful for various distributed storages layers built on top of RocksDB, as it should help reduce resources (time and network bandwidth) needed to recover and rebuilt DB instances as replicas in the context of distributed storages.
From the API standpoint that would like client app requesting iterator between (start seqnum) and current DB state, and reading the "diff".
This is a very draft PR for initial review in the discussion on the approach, i'm going to rework some parts and keep updating the PR.
For now, what's done here according to initial discussions:
Preserving deletes:
- We want to be able to optionally preserve recent deletes for some defined period of time, so that if a delete came in recently and might need to be included in the next incremental snapshot it would't get dropped by a compaction. This is done by adding new param to Options (preserve deletes flag) and new variable to DB Impl where we keep track of the sequence number after which we don't want to drop tombstones, even if they are otherwise eligible for deletion.
- I also added a new API call for clients to be able to advance this cutoff seqnum after which we drop deletes; i assume it's more flexible to let clients control this, since otherwise we'd need to keep some kind of timestamp < -- > seqnum mapping inside the DB, which sounds messy and painful to support. Clients could make use of it by periodically calling GetLatestSequenceNumber(), noting the timestamp, doing some calculation and figuring out by how much we need to advance the cutoff seqnum.
- Compaction codepath in compaction_iterator.cc has been modified to avoid dropping tombstones with seqnum > cutoff seqnum.
Iterator changes:
- couple params added to ReadOptions, to optionally allow client to request internal keys instead of user keys (so that client can get the latest value of a key, be it delete marker or a put), as well as min timestamp and min seqnum.
TableCache changes:
- I modified table_cache code to be able to quickly exclude SST files from iterators heep if creation_time on the file is less then iter_start_ts as passed in ReadOptions. That would help a lot in some DB settings (like reading very recent data only or using FIFO compactions), but not so much for universal compaction with more or less long iterator time span.
What's left:
- Still looking at how to best plug that inside DBIter codepath. So far it seems that FindNextUserKeyInternal only parses values as UserKeys, and iter->key() call generally returns user key. Can we add new API to DBIter as internal_key(), and modify this internal method to optionally set saved_key_ to point to the full internal key? I don't need to store actual seqnum there, but I do need to store type.
Closes https://github.com/facebook/rocksdb/pull/2999
Differential Revision: D6175602
Pulled By: mikhail-antonov
fbshipit-source-id: c779a6696ee2d574d86c69cec866a3ae095aa900
2017-11-02 02:43:29 +01:00
|
|
|
ignore_range_deletions(false),
|
|
|
|
iter_start_seqnum(0) {}
|
2015-02-18 20:49:31 +01:00
|
|
|
|
2013-10-04 06:49:15 +02:00
|
|
|
} // namespace rocksdb
|