mirror of https://github.com/facebook/rocksdb.git
Add --stats_interval_seconds to db_bench
Summary: The --stats_interval_seconds determines interval for stats reporting and overrides --stats_interval when set. I also changed tools/benchmark.sh to report stats every 60 seconds so I can avoid trying to figure out a good value for --stats_interval per test and per storage device. Task ID: #6631621 Blame Rev: Test Plan: run tools/run_flash_bench, look at output Revert Plan: Database Impact: Memcache Impact: Other Notes: EImportant: - begin *PUBLIC* platform impact section - Bugzilla: # - end platform impact - Reviewers: igor Reviewed By: igor Subscribers: dhruba Differential Revision: https://reviews.facebook.net/D36189
This commit is contained in:
parent
fd3dbef22b
commit
1bd70fb54a
|
@ -476,6 +476,9 @@ static rocksdb::Env* FLAGS_env = rocksdb::Env::Default();
|
|||
DEFINE_int64(stats_interval, 0, "Stats are reported every N operations when "
|
||||
"this is greater than zero. When 0 the interval grows over time.");
|
||||
|
||||
DEFINE_int64(stats_interval_seconds, 0, "Report stats every N seconds. This "
|
||||
"overrides stats_interval when both are > 0.");
|
||||
|
||||
DEFINE_int32(stats_per_interval, 0, "Reports additional stats per interval when"
|
||||
" this is greater than 0.");
|
||||
|
||||
|
@ -992,36 +995,49 @@ class Stats {
|
|||
fprintf(stderr, "... finished %" PRIu64 " ops%30s\r", done_, "");
|
||||
} else {
|
||||
double now = FLAGS_env->NowMicros();
|
||||
fprintf(stderr,
|
||||
"%s ... thread %d: (%" PRIu64 ",%" PRIu64 ") ops and "
|
||||
"(%.1f,%.1f) ops/second in (%.6f,%.6f) seconds\n",
|
||||
FLAGS_env->TimeToString((uint64_t) now/1000000).c_str(),
|
||||
id_,
|
||||
done_ - last_report_done_, done_,
|
||||
(done_ - last_report_done_) /
|
||||
((now - last_report_finish_) / 1000000.0),
|
||||
done_ / ((now - start_) / 1000000.0),
|
||||
(now - last_report_finish_) / 1000000.0,
|
||||
(now - start_) / 1000000.0);
|
||||
int64_t usecs_since_last = now - last_report_finish_;
|
||||
|
||||
if (FLAGS_stats_per_interval) {
|
||||
std::string stats;
|
||||
// Determine whether to print status where interval is either
|
||||
// each N operations or each N seconds.
|
||||
|
||||
if (db_with_cfh && db_with_cfh->num_created.load()) {
|
||||
for (size_t i = 0; i < db_with_cfh->num_created.load(); ++i) {
|
||||
if (db->GetProperty(db_with_cfh->cfh[i], "rocksdb.cfstats",
|
||||
&stats))
|
||||
fprintf(stderr, "%s\n", stats.c_str());
|
||||
if (FLAGS_stats_interval_seconds &&
|
||||
usecs_since_last < (FLAGS_stats_interval_seconds * 1000000)) {
|
||||
// Don't check again for this many operations
|
||||
next_report_ += FLAGS_stats_interval;
|
||||
|
||||
} else {
|
||||
|
||||
fprintf(stderr,
|
||||
"%s ... thread %d: (%" PRIu64 ",%" PRIu64 ") ops and "
|
||||
"(%.1f,%.1f) ops/second in (%.6f,%.6f) seconds\n",
|
||||
FLAGS_env->TimeToString((uint64_t) now/1000000).c_str(),
|
||||
id_,
|
||||
done_ - last_report_done_, done_,
|
||||
(done_ - last_report_done_) /
|
||||
(usecs_since_last / 1000000.0),
|
||||
done_ / ((now - start_) / 1000000.0),
|
||||
(now - last_report_finish_) / 1000000.0,
|
||||
(now - start_) / 1000000.0);
|
||||
|
||||
if (FLAGS_stats_per_interval) {
|
||||
std::string stats;
|
||||
|
||||
if (db_with_cfh && db_with_cfh->num_created.load()) {
|
||||
for (size_t i = 0; i < db_with_cfh->num_created.load(); ++i) {
|
||||
if (db->GetProperty(db_with_cfh->cfh[i], "rocksdb.cfstats",
|
||||
&stats))
|
||||
fprintf(stderr, "%s\n", stats.c_str());
|
||||
}
|
||||
|
||||
} else if (db && db->GetProperty("rocksdb.stats", &stats)) {
|
||||
fprintf(stderr, "%s\n", stats.c_str());
|
||||
}
|
||||
|
||||
} else if (db && db->GetProperty("rocksdb.stats", &stats)) {
|
||||
fprintf(stderr, "%s\n", stats.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
next_report_ += FLAGS_stats_interval;
|
||||
last_report_finish_ = now;
|
||||
last_report_done_ = done_;
|
||||
next_report_ += FLAGS_stats_interval;
|
||||
last_report_finish_ = now;
|
||||
last_report_done_ = done_;
|
||||
}
|
||||
}
|
||||
if (id_ == 0 && FLAGS_thread_status_per_interval) {
|
||||
PrintThreadStatus();
|
||||
|
@ -3389,6 +3405,12 @@ int main(int argc, char** argv) {
|
|||
FLAGS_db = default_db_path;
|
||||
}
|
||||
|
||||
if (FLAGS_stats_interval_seconds > 0) {
|
||||
// When both are set then FLAGS_stats_interval determines the frequency
|
||||
// at which the timer is checked for FLAGS_stats_interval_seconds
|
||||
FLAGS_stats_interval = 1000;
|
||||
}
|
||||
|
||||
rocksdb::Benchmark benchmark;
|
||||
benchmark.Run();
|
||||
return 0;
|
||||
|
|
|
@ -77,7 +77,7 @@ const_params="
|
|||
\
|
||||
--statistics=1 \
|
||||
--stats_per_interval=1 \
|
||||
--stats_interval=$((1 * M)) \
|
||||
--stats_interval_seconds=60 \
|
||||
--histogram=1 \
|
||||
\
|
||||
--memtablerep=skip_list \
|
||||
|
|
Loading…
Reference in New Issue