// Some functions that make it easier to optimize RocksDB
+ // Use this if your DB is very small (like under 1GB) and you don't want to
+ // spend lots of memory for memtables.
+ DBOptions* OptimizeForSmallDb();
+
#ifndef ROCKSDB_LITE
// By default, RocksDB uses only one background thread for flush and
// compaction. Calling this function will set it up such that total of
// If max_open_files is -1, DB will open all files on DB::Open(). You can
// use this option to increase the number of threads used to open the files.
- // Default: 1
+ // Default: 16
int max_file_opening_threads;
// Once write-ahead logs exceed this size, we will start forcing the flush of
void DumpCFOptions(Logger* log) const;
+ // Some functions that make it easier to optimize RocksDB
+
// Set appropriate parameters for bulk loading.
// The reason that this is a function that returns "this" instead of a
// constructor is to enable chaining of multiple similar calls in the future.
// It's recommended to manually call CompactRange(NULL, NULL) before reading
// from the database, because otherwise the read can be very slow.
Options* PrepareForBulkLoad();
+
+ // Use this if your DB is very small (like under 1GB) and you don't want to
+ // spend lots of memory for memtables.
+ Options* OptimizeForSmallDb();
};
//
return this;
}
+Options* Options::OptimizeForSmallDb() {
+ ColumnFamilyOptions::OptimizeForSmallDb();
+ DBOptions::OptimizeForSmallDb();
+ return this;
+}
+
Options* Options::OldDefaults(int rocksdb_major_version,
int rocksdb_minor_version) {
ColumnFamilyOptions::OldDefaults(rocksdb_major_version,
}
// Optimization functions
+DBOptions* DBOptions::OptimizeForSmallDb() {
+ max_file_opening_threads = 1;
+ max_open_files = 5000;
+ return this;
+}
+
ColumnFamilyOptions* ColumnFamilyOptions::OptimizeForSmallDb() {
write_buffer_size = 2 << 20;
target_file_size_base = 2 * 1048576;
old_default_cf_opts.compaction_pri);
}
- ColumnFamilyOptions cf_small_opts;
- cf_small_opts.OptimizeForSmallDb();
- ASSERT_EQ(2 << 20, cf_small_opts.write_buffer_size);
+ Options small_opts;
+ small_opts.OptimizeForSmallDb();
+ ASSERT_EQ(2 << 20, small_opts.write_buffer_size);
+ ASSERT_EQ(5000, small_opts.max_open_files);
}
class OptionsSanityCheckTest : public OptionsParserTest {