Skip to content

Commit 5576ded

Browse files
pdillingerfacebook-github-bot
authored andcommitted
Add Options::DisableExtraChecks, clarify force_consistency_checks (facebook#9363)
Summary: In response to facebook#9354, this PR adds a way for users to "opt out" of extra checks that can impact peak write performance, which currently only includes force_consistency_checks. I considered including some other options but did not see a db_bench performance difference. Also clarify in comment for force_consistency_checks that it can "slow down saturated writing." Pull Request resolved: facebook#9363 Test Plan: basic coverage in unit tests Using my perf test in facebook#9354 comment, I see force_consistency_checks=true -> 725360 ops/s force_consistency_checks=false -> 783072 ops/s Reviewed By: mrambacher Differential Revision: D33636559 Pulled By: pdillinger fbshipit-source-id: 25bfd006f4844675e7669b342817dd4c6a641e84
1 parent 288dfd0 commit 5576ded

File tree

7 files changed

+53
-4
lines changed

7 files changed

+53
-4
lines changed

DEFAULT_OPTIONS_HISTORY.md

+1-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
# RocksDB default options change log
1+
# RocksDB default options change log (NO LONGER MAINTAINED)
22
## Unreleased
33
* delayed_write_rate takes the rate given by rate_limiter if not specified.
44

HISTORY.md

+4
Original file line numberDiff line numberDiff line change
@@ -4,11 +4,15 @@
44
* Added values to `TraceFilterType`: `kTraceFilterIteratorSeek`, `kTraceFilterIteratorSeekForPrev`, and `kTraceFilterMultiGet`. They can be set in `TraceOptions` to filter out the operation types after which they are named.
55
* Added `TraceOptions::preserve_write_order`. When enabled it guarantees write records are traced in the same order they are logged to WAL and applied to the DB. By default it is disabled (false) to match the legacy behavior and prevent regression.
66
* Made the Env class extend the Customizable class. Implementations need to be registered with the ObjectRegistry and to implement a Name() method in order to be created via this method.
7+
* `Options::OldDefaults` is marked deprecated, as it is no longer maintained.
78
* Add ObjectLibrary::AddFactory and ObjectLibrary::PatternEntry classes. This method and associated class are the preferred mechanism for registering factories with the ObjectLibrary going forward. The ObjectLibrary::Register method, which uses regular expressions and may be problematic, is deprecated and will be in a future release.
89

910
### Behavior Changes
1011
* `DB::DestroyColumnFamilyHandle()` will return Status::InvalidArgument() if called with `DB::DefaultColumnFamily()`.
1112

13+
### New Features
14+
* Added `Options::DisableExtraChecks()` that can be used to improve peak write performance by disabling checks that should not be necessary in the absence of software logic errors or CPU+memory hardware errors. (Default options are slowly moving toward some performance overheads for extra correctness checking.)
15+
1216
### Bug Fixes
1317
* Fix a bug that FlushMemTable may return ok even flush not succeed.
1418

db/db_test_util.cc

+2
Original file line numberDiff line numberDiff line change
@@ -478,6 +478,8 @@ Options DBTestBase::GetOptions(
478478
break;
479479
case kXXH3Checksum: {
480480
table_options.checksum = kXXH3;
481+
// Thrown in here for basic coverage:
482+
options.DisableExtraChecks();
481483
break;
482484
}
483485
case kFIFOCompaction: {

include/rocksdb/advanced_options.h

+3-1
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,9 @@ struct AdvancedColumnFamilyOptions {
736736
// LSM changes (Flush, Compaction, AddFile). When this option is true, these
737737
// checks are also enabled in release mode. These checks were historically
738738
// disabled in release mode, but are now enabled by default for proactive
739-
// corruption detection, at almost no cost in extra CPU.
739+
// corruption detection. The CPU overhead is negligible for normal mixed
740+
// operations but can slow down saturated writing. See
741+
// Options::DisableExtraChecks().
740742
// Default: true
741743
bool force_consistency_checks = true;
742744

include/rocksdb/options.h

+11-1
Original file line numberDiff line numberDiff line change
@@ -1365,7 +1365,11 @@ struct Options : public DBOptions, public ColumnFamilyOptions {
13651365
const ColumnFamilyOptions& column_family_options)
13661366
: DBOptions(db_options), ColumnFamilyOptions(column_family_options) {}
13671367

1368-
// The function recovers options to the option as in version 4.6.
1368+
// Change to some default settings from an older version.
1369+
// NOT MAINTAINED: This function has not been and is not maintained.
1370+
// DEPRECATED: This function might be removed in a future release.
1371+
// In general, defaults are changed to suit broad interests. Opting
1372+
// out of a change on upgrade should be deliberate and considered.
13691373
Options* OldDefaults(int rocksdb_major_version = 4,
13701374
int rocksdb_minor_version = 6);
13711375

@@ -1388,6 +1392,12 @@ struct Options : public DBOptions, public ColumnFamilyOptions {
13881392
// Use this if your DB is very small (like under 1GB) and you don't want to
13891393
// spend lots of memory for memtables.
13901394
Options* OptimizeForSmallDb();
1395+
1396+
// Disable some checks that should not be necessary in the absence of
1397+
// software logic errors or CPU+memory hardware errors. This can improve
1398+
// write speeds but is only recommended for temporary use. Does not
1399+
// change protection against corrupt storage (e.g. verify_checksums).
1400+
Options* DisableExtraChecks();
13911401
};
13921402

13931403
//

options/options.cc

+13
Original file line numberDiff line numberDiff line change
@@ -474,6 +474,19 @@ Options* Options::OptimizeForSmallDb() {
474474
return this;
475475
}
476476

477+
Options* Options::DisableExtraChecks() {
478+
// See https://github.com/facebook/rocksdb/issues/9354
479+
force_consistency_checks = false;
480+
// Considered but no clear performance impact seen:
481+
// * check_flush_compaction_key_order
482+
// * paranoid_checks
483+
// * flush_verify_memtable_count
484+
// By current API contract, not including
485+
// * verify_checksums
486+
// because checking storage data integrity is a more standard practice.
487+
return this;
488+
}
489+
477490
Options* Options::OldDefaults(int rocksdb_major_version,
478491
int rocksdb_minor_version) {
479492
ColumnFamilyOptions::OldDefaults(rocksdb_major_version,

tools/db_bench_tool.cc

+19-1
Original file line numberDiff line numberDiff line change
@@ -837,11 +837,25 @@ DEFINE_int32(deletepercent, 2, "Percentage of deletes out of reads/writes/"
837837
"deletepercent), so deletepercent must be smaller than (100 - "
838838
"FLAGS_readwritepercent)");
839839

840-
DEFINE_bool(optimize_filters_for_hits, false,
840+
DEFINE_bool(optimize_filters_for_hits,
841+
ROCKSDB_NAMESPACE::Options().optimize_filters_for_hits,
841842
"Optimizes bloom filters for workloads for most lookups return "
842843
"a value. For now this doesn't create bloom filters for the max "
843844
"level of the LSM to reduce metadata that should fit in RAM. ");
844845

846+
DEFINE_bool(paranoid_checks, ROCKSDB_NAMESPACE::Options().paranoid_checks,
847+
"RocksDB will aggressively check consistency of the data.");
848+
849+
DEFINE_bool(force_consistency_checks,
850+
ROCKSDB_NAMESPACE::Options().force_consistency_checks,
851+
"Runs consistency checks on the LSM every time a change is "
852+
"applied.");
853+
854+
DEFINE_bool(check_flush_compaction_key_order,
855+
ROCKSDB_NAMESPACE::Options().check_flush_compaction_key_order,
856+
"During flush or compaction, check whether keys inserted to "
857+
"output files are in order.");
858+
845859
DEFINE_uint64(delete_obsolete_files_period_micros, 0,
846860
"Ignored. Left here for backward compatibility");
847861

@@ -4304,6 +4318,10 @@ class Benchmark {
43044318
options.max_compaction_bytes = FLAGS_max_compaction_bytes;
43054319
options.disable_auto_compactions = FLAGS_disable_auto_compactions;
43064320
options.optimize_filters_for_hits = FLAGS_optimize_filters_for_hits;
4321+
options.paranoid_checks = FLAGS_paranoid_checks;
4322+
options.force_consistency_checks = FLAGS_force_consistency_checks;
4323+
options.check_flush_compaction_key_order =
4324+
FLAGS_check_flush_compaction_key_order;
43074325
options.periodic_compaction_seconds = FLAGS_periodic_compaction_seconds;
43084326
options.ttl = FLAGS_ttl_seconds;
43094327
// fill storage options

0 commit comments

Comments
 (0)