mirror of https://github.com/facebook/rocksdb.git
Configure direct I/O statically in db_stress
Summary: Previously `db_stress` attempted to configure direct I/O dynamically in `SetOptions()` which had multiple problems (ummm must've never been tested): - It's a DB option so SetDBOptions should've been called instead - It's not a dynamic option so even SetDBOptions would fail - It required enabling SyncPoint to mask O_DIRECT since it had no way to detect whether the DB directory was in tmpfs or not. This required locking that consumed ~80% of db_stress CPU. In this PR I delete the broken dynamic config and instead configure it statically, only enabling it if the DB directory truly supports O_DIRECT. Closes https://github.com/facebook/rocksdb/pull/3939 Differential Revision: D8238120 Pulled By: ajkr fbshipit-source-id: 60bb2deebe6c9b54a3f788079261715b4a229279
This commit is contained in:
parent
01e3c30def
commit
88c3ee2d31
|
@ -43,6 +43,8 @@ default_params = {
|
|||
"subcompactions": lambda: random.randint(1, 4),
|
||||
"target_file_size_base": 2097152,
|
||||
"target_file_size_multiplier": 2,
|
||||
"use_direct_reads": lambda: random.randint(0, 1),
|
||||
"use_direct_io_for_flush_and_compaction": lambda: random.randint(0, 1),
|
||||
"use_full_merge_v1": lambda: random.randint(0, 1),
|
||||
"use_merge": lambda: random.randint(0, 1),
|
||||
"verify_checksum": 1,
|
||||
|
@ -58,8 +60,19 @@ def get_dbname(test_name):
|
|||
else:
|
||||
dbname = test_tmpdir + "/rocksdb_crashtest_" + test_name
|
||||
shutil.rmtree(dbname, True)
|
||||
os.mkdir(dbname)
|
||||
return dbname
|
||||
|
||||
|
||||
def is_direct_io_supported(dbname):
|
||||
with tempfile.NamedTemporaryFile(dir=dbname) as f:
|
||||
try:
|
||||
os.open(f.name, os.O_DIRECT)
|
||||
except:
|
||||
return False
|
||||
return True
|
||||
|
||||
|
||||
blackbox_default_params = {
|
||||
# total time for this script to test db_stress
|
||||
"duration": 6000,
|
||||
|
@ -107,6 +120,10 @@ def finalize_and_sanitize(src_params):
|
|||
for (k, v) in src_params.items()])
|
||||
if dest_params.get("allow_concurrent_memtable_write", 1) == 1:
|
||||
dest_params["memtablerep"] = "skip_list"
|
||||
if dest_params["mmap_read"] == 1 or not is_direct_io_supported(
|
||||
dest_params["db"]):
|
||||
dest_params["use_direct_io_for_flush_and_compaction"] = 0
|
||||
dest_params["use_direct_reads"] = 0
|
||||
return dest_params
|
||||
|
||||
|
||||
|
|
|
@ -1397,8 +1397,6 @@ class StressTest {
|
|||
ToString(options_.max_bytes_for_level_multiplier), "1", "2",
|
||||
}},
|
||||
{"max_sequential_skip_in_iterations", {"4", "8", "12"}},
|
||||
{"use_direct_reads", {"false", "true"}},
|
||||
{"use_direct_io_for_flush_and_compaction", {"false", "true"}},
|
||||
};
|
||||
|
||||
options_table_ = std::move(options_tbl);
|
||||
|
@ -2837,20 +2835,6 @@ int main(int argc, char** argv) {
|
|||
SetUsageMessage(std::string("\nUSAGE:\n") + std::string(argv[0]) +
|
||||
" [OPTIONS]...");
|
||||
ParseCommandLineFlags(&argc, &argv, true);
|
||||
#if !defined(NDEBUG) && !defined(OS_MACOSX) && !defined(OS_WIN) && \
|
||||
!defined(OS_SOLARIS) && !defined(OS_AIX)
|
||||
rocksdb::SyncPoint::GetInstance()->SetCallBack(
|
||||
"NewWritableFile:O_DIRECT", [&](void* arg) {
|
||||
int* val = static_cast<int*>(arg);
|
||||
*val &= ~O_DIRECT;
|
||||
});
|
||||
rocksdb::SyncPoint::GetInstance()->SetCallBack(
|
||||
"NewRandomAccessFile:O_DIRECT", [&](void* arg) {
|
||||
int* val = static_cast<int*>(arg);
|
||||
*val &= ~O_DIRECT;
|
||||
});
|
||||
rocksdb::SyncPoint::GetInstance()->EnableProcessing();
|
||||
#endif
|
||||
|
||||
if (FLAGS_statistics) {
|
||||
dbstats = rocksdb::CreateDBStatistics();
|
||||
|
|
Loading…
Reference in New Issue