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).
|
2014-09-17 21:49:13 +02:00
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2017-02-07 19:35:15 +01:00
|
|
|
#include <map>
|
2014-11-18 22:21:02 +01:00
|
|
|
#include <stdexcept>
|
2016-09-20 22:02:41 +02:00
|
|
|
#include <string>
|
Add OptionsUtil::LoadOptionsFromFile() API
Summary:
This patch adds OptionsUtil::LoadOptionsFromFile() and
OptionsUtil::LoadLatestOptionsFromDB(), which allow developers
to construct DBOptions and ColumnFamilyOptions from a RocksDB
options file. Note that most pointer-typed options such as
merge_operator will not be constructed.
With this API, developers no longer need to remember all the
options in order to reopen an existing rocksdb instance like
the following:
DBOptions db_options;
std::vector<std::string> cf_names;
std::vector<ColumnFamilyOptions> cf_opts;
// Load primitive-typed options from an existing DB
OptionsUtil::LoadLatestOptionsFromDB(
dbname, &db_options, &cf_names, &cf_opts);
// Initialize necessary pointer-typed options
cf_opts[0].merge_operator.reset(new MyMergeOperator());
...
// Construct the vector of ColumnFamilyDescriptor
std::vector<ColumnFamilyDescriptor> cf_descs;
for (size_t i = 0; i < cf_opts.size(); ++i) {
cf_descs.emplace_back(cf_names[i], cf_opts[i]);
}
// Open the DB
DB* db = nullptr;
std::vector<ColumnFamilyHandle*> cf_handles;
auto s = DB::Open(db_options, dbname, cf_descs,
&handles, &db);
Test Plan:
Augment existing tests in column_family_test
options_test
db_test
Reviewers: igor, IslamAbdelRahman, sdong, anthony
Reviewed By: anthony
Subscribers: dhruba, leveldb
Differential Revision: https://reviews.facebook.net/D49095
2015-11-12 15:52:43 +01:00
|
|
|
#include <vector>
|
|
|
|
|
New backup meta schema, with file temperatures (#9660)
Summary:
The primary goal of this change is to add support for backing up and
restoring (applying on restore) file temperature metadata, without
committing to either the DB manifest or the FS reported "current"
temperatures being exclusive "source of truth".
To achieve this goal, we need to add temperature information to backup
metadata, which requires updated backup meta schema. Fortunately I
prepared for this in https://github.com/facebook/rocksdb/issues/8069, which began forward compatibility in version
6.19.0 for this kind of schema update. (Previously, backup meta schema
was not extensible! Making this schema update public will allow some
other "nice to have" features like taking backups with hard links, and
avoiding crc32c checksum computation when another checksum is already
available.) While schema version 2 is newly public, the default schema
version is still 1. Until we change the default, users will need to set
to 2 to enable features like temperature data backup+restore. New
metadata like temperature information will be ignored with a warning
in versions before this change and since 6.19.0. The metadata is
considered ignorable because a functioning DB can be restored without
it.
Some detail:
* Some renaming because "future schema" is now just public schema 2.
* Initialize some atomics in TestFs (linter reported)
* Add temperature hint support to SstFileDumper (used by BackupEngine)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9660
Test Plan:
related unit test majorly updated for the new functionality,
including some shared testing support for tracking temperatures in a FS.
Some other tests and testing hooks into production code also updated for
making the backup meta schema change public.
Reviewed By: ajkr
Differential Revision: D34686968
Pulled By: pdillinger
fbshipit-source-id: 3ac1fa3e67ee97ca8a5103d79cc87d872c1d862a
2022-03-18 19:06:17 +01:00
|
|
|
#include "rocksdb/advanced_options.h"
|
2015-08-27 01:13:56 +02:00
|
|
|
#include "rocksdb/options.h"
|
2014-11-05 01:23:05 +01:00
|
|
|
#include "rocksdb/status.h"
|
2015-10-11 21:17:42 +02:00
|
|
|
#include "rocksdb/table.h"
|
2014-09-17 21:49:13 +02:00
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
namespace ROCKSDB_NAMESPACE {
|
2020-09-15 01:59:00 +02:00
|
|
|
struct ColumnFamilyOptions;
|
2020-04-22 02:35:28 +02:00
|
|
|
struct ConfigOptions;
|
2020-09-15 01:59:00 +02:00
|
|
|
struct DBOptions;
|
2021-04-23 05:42:50 +02:00
|
|
|
struct ImmutableCFOptions;
|
2020-09-15 01:59:00 +02:00
|
|
|
struct ImmutableDBOptions;
|
|
|
|
struct MutableDBOptions;
|
|
|
|
struct MutableCFOptions;
|
|
|
|
struct Options;
|
2014-09-17 21:49:13 +02:00
|
|
|
|
2020-04-25 00:30:12 +02:00
|
|
|
std::vector<CompressionType> GetSupportedCompressions();
|
|
|
|
|
2020-11-03 04:20:15 +01:00
|
|
|
std::vector<CompressionType> GetSupportedDictCompressions();
|
|
|
|
|
Implement XXH3 block checksum type (#9069)
Summary:
XXH3 - latest hash function that is extremely fast on large
data, easily faster than crc32c on most any x86_64 hardware. In
integrating this hash function, I have handled the compression type byte
in a non-standard way to avoid using the streaming API (extra data
movement and active code size because of hash function complexity). This
approach got a thumbs-up from Yann Collet.
Existing functionality change:
* reject bad ChecksumType in options with InvalidArgument
This change split off from https://github.com/facebook/rocksdb/issues/9058 because context-aware checksum is
likely to be handled through different configuration than ChecksumType.
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9069
Test Plan:
tests updated, and substantially expanded. Unit tests now check
that we don't accidentally change the values generated by the checksum
algorithms ("schema test") and that we properly handle
invalid/unrecognized checksum types in options or in file footer.
DBTestBase::ChangeOptions (etc.) updated from two to one configuration
changing from default CRC32c ChecksumType. The point of this test code
is to detect possible interactions among features, and the likelihood of
some bad interaction being detected by including configurations other
than XXH3 and CRC32c--and then not detected by stress/crash test--is
extremely low.
Stress/crash test also updated (manual run long enough to see it accepts
new checksum type). db_bench also updated for microbenchmarking
checksums.
### Performance microbenchmark (PORTABLE=0 DEBUG_LEVEL=0, Broadwell processor)
./db_bench -benchmarks=crc32c,xxhash,xxhash64,xxh3,crc32c,xxhash,xxhash64,xxh3,crc32c,xxhash,xxhash64,xxh3
crc32c : 0.200 micros/op 5005220 ops/sec; 19551.6 MB/s (4096 per op)
xxhash : 0.807 micros/op 1238408 ops/sec; 4837.5 MB/s (4096 per op)
xxhash64 : 0.421 micros/op 2376514 ops/sec; 9283.3 MB/s (4096 per op)
xxh3 : 0.171 micros/op 5858391 ops/sec; 22884.3 MB/s (4096 per op)
crc32c : 0.206 micros/op 4859566 ops/sec; 18982.7 MB/s (4096 per op)
xxhash : 0.793 micros/op 1260850 ops/sec; 4925.2 MB/s (4096 per op)
xxhash64 : 0.410 micros/op 2439182 ops/sec; 9528.1 MB/s (4096 per op)
xxh3 : 0.161 micros/op 6202872 ops/sec; 24230.0 MB/s (4096 per op)
crc32c : 0.203 micros/op 4924686 ops/sec; 19237.1 MB/s (4096 per op)
xxhash : 0.839 micros/op 1192388 ops/sec; 4657.8 MB/s (4096 per op)
xxhash64 : 0.424 micros/op 2357391 ops/sec; 9208.6 MB/s (4096 per op)
xxh3 : 0.162 micros/op 6182678 ops/sec; 24151.1 MB/s (4096 per op)
As you can see, especially once warmed up, xxh3 is fastest.
### Performance macrobenchmark (PORTABLE=0 DEBUG_LEVEL=0, Broadwell processor)
Test
for I in `seq 1 50`; do for CHK in 0 1 2 3 4; do TEST_TMPDIR=/dev/shm/rocksdb$CHK ./db_bench -benchmarks=fillseq -memtablerep=vector -allow_concurrent_memtable_write=false -num=30000000 -checksum_type=$CHK 2>&1 | grep 'micros/op' | tee -a results-$CHK & done; wait; done
Results (ops/sec)
for FILE in results*; do echo -n "$FILE "; awk '{ s += $5; c++; } END { print 1.0 * s / c; }' < $FILE; done
results-0 252118 # kNoChecksum
results-1 251588 # kCRC32c
results-2 251863 # kxxHash
results-3 252016 # kxxHash64
results-4 252038 # kXXH3
Reviewed By: mrambacher
Differential Revision: D31905249
Pulled By: pdillinger
fbshipit-source-id: cb9b998ebe2523fc7c400eedf62124a78bf4b4d1
2021-10-29 07:13:47 +02:00
|
|
|
std::vector<ChecksumType> GetSupportedChecksums();
|
|
|
|
|
2021-11-04 17:08:12 +01:00
|
|
|
inline bool IsSupportedChecksumType(ChecksumType type) {
|
2021-11-04 22:59:37 +01:00
|
|
|
// Avoid annoying compiler warning-as-error (-Werror=type-limits)
|
|
|
|
auto min = kNoChecksum;
|
|
|
|
auto max = kXXH3;
|
|
|
|
return type >= min && type <= max;
|
2021-11-04 17:08:12 +01:00
|
|
|
}
|
|
|
|
|
2020-09-15 01:59:00 +02:00
|
|
|
// Checks that the combination of DBOptions and ColumnFamilyOptions are valid
|
|
|
|
Status ValidateOptions(const DBOptions& db_opts,
|
|
|
|
const ColumnFamilyOptions& cf_opts);
|
|
|
|
|
2016-09-24 01:34:04 +02:00
|
|
|
DBOptions BuildDBOptions(const ImmutableDBOptions& immutable_db_options,
|
|
|
|
const MutableDBOptions& mutable_db_options);
|
|
|
|
|
2016-09-15 07:10:28 +02:00
|
|
|
ColumnFamilyOptions BuildColumnFamilyOptions(
|
|
|
|
const ColumnFamilyOptions& ioptions,
|
|
|
|
const MutableCFOptions& mutable_cf_options);
|
2021-05-05 22:59:21 +02:00
|
|
|
|
|
|
|
void UpdateColumnFamilyOptions(const ImmutableCFOptions& ioptions,
|
|
|
|
ColumnFamilyOptions* cf_opts);
|
|
|
|
void UpdateColumnFamilyOptions(const MutableCFOptions& moptions,
|
|
|
|
ColumnFamilyOptions* cf_opts);
|
2016-09-15 07:10:28 +02:00
|
|
|
|
|
|
|
#ifndef ROCKSDB_LITE
|
2020-09-15 01:59:00 +02:00
|
|
|
std::unique_ptr<Configurable> DBOptionsAsConfigurable(
|
|
|
|
const MutableDBOptions& opts);
|
2021-10-19 19:42:04 +02:00
|
|
|
std::unique_ptr<Configurable> DBOptionsAsConfigurable(
|
|
|
|
const DBOptions& opts,
|
|
|
|
const std::unordered_map<std::string, std::string>* opt_map = nullptr);
|
2020-09-15 01:59:00 +02:00
|
|
|
std::unique_ptr<Configurable> CFOptionsAsConfigurable(
|
|
|
|
const MutableCFOptions& opts);
|
|
|
|
std::unique_ptr<Configurable> CFOptionsAsConfigurable(
|
|
|
|
const ColumnFamilyOptions& opts,
|
|
|
|
const std::unordered_map<std::string, std::string>* opt_map = nullptr);
|
|
|
|
|
2017-07-29 01:23:50 +02:00
|
|
|
extern Status StringToMap(
|
|
|
|
const std::string& opts_str,
|
|
|
|
std::unordered_map<std::string, std::string>* opts_map);
|
2016-09-15 07:10:28 +02:00
|
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
|
2017-11-18 02:02:13 +01:00
|
|
|
struct OptionsHelper {
|
2020-09-15 01:59:00 +02:00
|
|
|
static const std::string kCFOptionsName /*= "ColumnFamilyOptions"*/;
|
|
|
|
static const std::string kDBOptionsName /*= "DBOptions" */;
|
2017-11-18 02:02:13 +01:00
|
|
|
static std::map<CompactionStyle, std::string> compaction_style_to_string;
|
|
|
|
static std::map<CompactionPri, std::string> compaction_pri_to_string;
|
|
|
|
static std::map<CompactionStopStyle, std::string>
|
|
|
|
compaction_stop_style_to_string;
|
New backup meta schema, with file temperatures (#9660)
Summary:
The primary goal of this change is to add support for backing up and
restoring (applying on restore) file temperature metadata, without
committing to either the DB manifest or the FS reported "current"
temperatures being exclusive "source of truth".
To achieve this goal, we need to add temperature information to backup
metadata, which requires updated backup meta schema. Fortunately I
prepared for this in https://github.com/facebook/rocksdb/issues/8069, which began forward compatibility in version
6.19.0 for this kind of schema update. (Previously, backup meta schema
was not extensible! Making this schema update public will allow some
other "nice to have" features like taking backups with hard links, and
avoiding crc32c checksum computation when another checksum is already
available.) While schema version 2 is newly public, the default schema
version is still 1. Until we change the default, users will need to set
to 2 to enable features like temperature data backup+restore. New
metadata like temperature information will be ignored with a warning
in versions before this change and since 6.19.0. The metadata is
considered ignorable because a functioning DB can be restored without
it.
Some detail:
* Some renaming because "future schema" is now just public schema 2.
* Initialize some atomics in TestFs (linter reported)
* Add temperature hint support to SstFileDumper (used by BackupEngine)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9660
Test Plan:
related unit test majorly updated for the new functionality,
including some shared testing support for tracking temperatures in a FS.
Some other tests and testing hooks into production code also updated for
making the backup meta schema change public.
Reviewed By: ajkr
Differential Revision: D34686968
Pulled By: pdillinger
fbshipit-source-id: 3ac1fa3e67ee97ca8a5103d79cc87d872c1d862a
2022-03-18 19:06:17 +01:00
|
|
|
static std::map<Temperature, std::string> temperature_to_string;
|
2017-11-18 02:02:13 +01:00
|
|
|
static std::unordered_map<std::string, ChecksumType> checksum_type_string_map;
|
2018-01-23 23:36:54 +01:00
|
|
|
static std::unordered_map<std::string, CompressionType>
|
|
|
|
compression_type_string_map;
|
2017-11-18 02:02:13 +01:00
|
|
|
#ifndef ROCKSDB_LITE
|
2017-12-11 22:12:12 +01:00
|
|
|
static std::unordered_map<std::string, CompactionStopStyle>
|
|
|
|
compaction_stop_style_string_map;
|
2017-11-18 02:02:13 +01:00
|
|
|
static std::unordered_map<std::string, EncodingType> encoding_type_string_map;
|
|
|
|
static std::unordered_map<std::string, CompactionStyle>
|
|
|
|
compaction_style_string_map;
|
|
|
|
static std::unordered_map<std::string, CompactionPri>
|
|
|
|
compaction_pri_string_map;
|
2022-01-25 23:58:48 +01:00
|
|
|
static std::unordered_map<std::string, Temperature> temperature_string_map;
|
2017-11-18 02:02:13 +01:00
|
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
};
|
|
|
|
|
|
|
|
// Some aliasing
|
|
|
|
static auto& compaction_style_to_string =
|
|
|
|
OptionsHelper::compaction_style_to_string;
|
|
|
|
static auto& compaction_pri_to_string = OptionsHelper::compaction_pri_to_string;
|
|
|
|
static auto& compaction_stop_style_to_string =
|
|
|
|
OptionsHelper::compaction_stop_style_to_string;
|
New backup meta schema, with file temperatures (#9660)
Summary:
The primary goal of this change is to add support for backing up and
restoring (applying on restore) file temperature metadata, without
committing to either the DB manifest or the FS reported "current"
temperatures being exclusive "source of truth".
To achieve this goal, we need to add temperature information to backup
metadata, which requires updated backup meta schema. Fortunately I
prepared for this in https://github.com/facebook/rocksdb/issues/8069, which began forward compatibility in version
6.19.0 for this kind of schema update. (Previously, backup meta schema
was not extensible! Making this schema update public will allow some
other "nice to have" features like taking backups with hard links, and
avoiding crc32c checksum computation when another checksum is already
available.) While schema version 2 is newly public, the default schema
version is still 1. Until we change the default, users will need to set
to 2 to enable features like temperature data backup+restore. New
metadata like temperature information will be ignored with a warning
in versions before this change and since 6.19.0. The metadata is
considered ignorable because a functioning DB can be restored without
it.
Some detail:
* Some renaming because "future schema" is now just public schema 2.
* Initialize some atomics in TestFs (linter reported)
* Add temperature hint support to SstFileDumper (used by BackupEngine)
Pull Request resolved: https://github.com/facebook/rocksdb/pull/9660
Test Plan:
related unit test majorly updated for the new functionality,
including some shared testing support for tracking temperatures in a FS.
Some other tests and testing hooks into production code also updated for
making the backup meta schema change public.
Reviewed By: ajkr
Differential Revision: D34686968
Pulled By: pdillinger
fbshipit-source-id: 3ac1fa3e67ee97ca8a5103d79cc87d872c1d862a
2022-03-18 19:06:17 +01:00
|
|
|
static auto& temperature_to_string = OptionsHelper::temperature_to_string;
|
2017-11-18 02:02:13 +01:00
|
|
|
static auto& checksum_type_string_map = OptionsHelper::checksum_type_string_map;
|
|
|
|
#ifndef ROCKSDB_LITE
|
2017-12-11 22:12:12 +01:00
|
|
|
static auto& compaction_stop_style_string_map =
|
|
|
|
OptionsHelper::compaction_stop_style_string_map;
|
2017-11-18 02:02:13 +01:00
|
|
|
static auto& compression_type_string_map =
|
|
|
|
OptionsHelper::compression_type_string_map;
|
|
|
|
static auto& encoding_type_string_map = OptionsHelper::encoding_type_string_map;
|
|
|
|
static auto& compaction_style_string_map =
|
|
|
|
OptionsHelper::compaction_style_string_map;
|
|
|
|
static auto& compaction_pri_string_map =
|
|
|
|
OptionsHelper::compaction_pri_string_map;
|
2022-01-25 23:58:48 +01:00
|
|
|
static auto& temperature_string_map = OptionsHelper::temperature_string_map;
|
2017-11-18 02:02:13 +01:00
|
|
|
#endif // !ROCKSDB_LITE
|
|
|
|
|
2020-02-20 21:07:53 +01:00
|
|
|
} // namespace ROCKSDB_NAMESPACE
|