add an option to disable seek compaction

Summary:
as subject. This diff should be good for benchmarking.

will send another diff to make it better in the case the seek compaction is enable.
In that coming diff, will not count a seek if the bloomfilter filters.

Test Plan: build

Reviewers: dhruba, MarkCallaghan

Reviewed By: MarkCallaghan

Differential Revision: https://reviews.facebook.net/D5481
This commit is contained in:
heyongqiang 2012-09-17 13:35:57 -07:00
parent 906f2ee1f1
commit a8464ed820
4 changed files with 18 additions and 3 deletions

View File

@ -161,6 +161,9 @@ static int FLAGS_level0_slowdown_writes_trigger = 8;
// setting is 9 gets for every 1 put.
static int FLAGS_readwritepercent = 90;
// Option to disable compation triggered by read.
static int FLAGS_disable_seek_compaction = false;
// Algorithm to use to compress the database
static enum leveldb::CompressionType FLAGS_compression_type =
leveldb::kSnappyCompression;
@ -850,6 +853,7 @@ class Benchmark {
options.level0_slowdown_writes_trigger =
FLAGS_level0_slowdown_writes_trigger;
options.compression = FLAGS_compression_type;
options.disable_seek_compaction = FLAGS_disable_seek_compaction;
Status s = DB::Open(options, FLAGS_db, &db_);
if (!s.ok()) {
fprintf(stderr, "open error: %s\n", s.ToString().c_str());
@ -1245,6 +1249,9 @@ int main(int argc, char** argv) {
else {
fprintf(stdout, "Cannot parse %s\n", argv[i]);
}
} else if (sscanf(argv[i], "--disable_seek_compaction=%d%c", &n, &junk) == 1
&& (n == 0 || n == 1)) {
FLAGS_disable_seek_compaction = n;
} else {
fprintf(stderr, "Invalid flag '%s'\n", argv[i]);
exit(1);

View File

@ -1380,7 +1380,7 @@ Compaction* VersionSet::PickCompaction() {
// Wrap-around to the beginning of the key space
c->inputs_[0].push_back(current_->files_[level][0]);
}
} else if (seek_compaction) {
} else if (seek_compaction && !options_->disable_seek_compaction) {
level = current_->file_to_compact_level_;
c = new Compaction(level, MaxFileSizeForLevel(level),
MaxGrandParentOverlapBytes(level), NumberLevels());

View File

@ -220,6 +220,12 @@ struct Options {
// name's prefix.
std::string db_log_dir;
// Disable compaction triggered by seek.
// With bloomfilter and fast storage, a miss on one level
// is very cheap if the file handle is cached in table cache
// (which is true if max_open_files is large).
bool disable_seek_compaction;
// Create an Options object with default values for all fields.
Options();

View File

@ -39,7 +39,8 @@ Options::Options()
disableDataSync(false),
use_fsync(false),
db_stats_log_interval(1800),
db_log_dir("") {
db_log_dir(""),
disable_seek_compaction(false) {
}
void
@ -87,7 +88,8 @@ Options::Dump(
max_grandparent_overlap_factor);
Log(log," Options.db_log_dir: %s",
db_log_dir.c_str());
Log(log," Options.disable_seek_compaction: %d",
disable_seek_compaction);
} // Options::Dump