]> git-server-git.apps.pok.os.sepia.ceph.com Git - rocksdb.git/commitdiff
[RocksDB] Add mmap_read option for db_stress
authorHaobo Xu <haobo@fb.com>
Mon, 17 Jun 2013 23:13:32 +0000 (16:13 -0700)
committerHaobo Xu <haobo@fb.com>
Wed, 19 Jun 2013 17:28:32 +0000 (10:28 -0700)
Summary: as title, also removed an incorrect assertion

Test Plan: make check; db_stress --mmap_read=1; db_stress --mmap_read=0

Reviewers: dhruba, emayanke

CC: leveldb
Differential Revision: https://reviews.facebook.net/D11367

include/leveldb/options.h
tools/db_stress.cc
util/env_posix.cc

index 79d0946ec838590fad459cecaadbfd6aae792c50..fa69a7eff8668aa6695ad941e742cfc6bd0c852b 100644 (file)
@@ -427,7 +427,7 @@ struct Options {
   // Note: Deprecated
   bool allow_readahead_compactions;
 
-  // Allow the OS to mmap file for reading. Default: false
+  // Allow the OS to mmap file for reading sst tables. Default: false
   bool allow_mmap_reads;
 
   // Allow the OS to mmap file for writing. Default: true
index a5cb5b35e8a4d2eeba2fbc987b60ee2748cb517c..02afe306cf36df9a8d3b372944c9f8bac89bc144 100644 (file)
@@ -110,6 +110,9 @@ static const char* FLAGS_db = nullptr;
 // Verify checksum for every block read from storage
 static bool FLAGS_verify_checksum = false;
 
+// Allow reads to occur via mmap-ing files
+static bool FLAGS_use_mmap_reads = leveldb::EnvOptions().use_mmap_reads;
+
 // Database statistics
 static std::shared_ptr<leveldb::Statistics> dbstats;
 
@@ -934,6 +937,7 @@ class StressTest {
     options.env = FLAGS_env;
     options.disableDataSync = FLAGS_disable_data_sync;
     options.use_fsync = FLAGS_use_fsync;
+    options.allow_mmap_reads = FLAGS_use_mmap_reads;
     leveldb_kill_odds = FLAGS_kill_random_test;
     options.target_file_size_base = FLAGS_target_file_size_base;
     options.target_file_size_multiplier = FLAGS_target_file_size_multiplier;
@@ -955,6 +959,9 @@ class StressTest {
     if (purge_percent.Uniform(100) < FLAGS_purge_redundant_percent - 1) {
       options.purge_redundant_kvs_while_flush = false;
     }
+
+    fprintf(stdout, "DB path: [%s]\n", FLAGS_db);
+
     Status s;
     if (FLAGS_ttl == -1) {
       s = DB::Open(options, FLAGS_db, &db_);
@@ -1076,6 +1083,9 @@ int main(int argc, char** argv) {
     } else if (sscanf(argv[i], "--verify_checksum=%d%c", &n, &junk) == 1 &&
                (n == 0 || n == 1)) {
       FLAGS_verify_checksum = n;
+    } else if (sscanf(argv[i], "--mmap_read=%d%c", &n, &junk) == 1 &&
+               (n == 0 || n == 1)) {
+      FLAGS_use_mmap_reads = n;
     } else if (sscanf(argv[i], "--statistics=%d%c", &n, &junk) == 1 &&
                (n == 0 || n == 1)) {
       if (n == 1) {
index 851030981e9cbd551ca28ff6be1df2ecee04c95a..4e24163a80e97fb57f87fb630f33f3f7104551e1 100644 (file)
@@ -108,7 +108,6 @@ class PosixSequentialFile: public SequentialFile {
       const EnvOptions& options)
       : filename_(fname), file_(f), fd_(fileno(f)),
         use_os_buffer_(options.use_os_buffer) {
-    assert(!options.use_mmap_reads);
   }
   virtual ~PosixSequentialFile() { fclose(file_); }