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
main
Mark Callaghan 10 years ago
parent fd3dbef22b
commit 1bd70fb54a
  1. 24
      db/db_bench.cc
  2. 2
      tools/benchmark.sh

@ -476,6 +476,9 @@ static rocksdb::Env* FLAGS_env = rocksdb::Env::Default();
DEFINE_int64(stats_interval, 0, "Stats are reported every N operations when " DEFINE_int64(stats_interval, 0, "Stats are reported every N operations when "
"this is greater than zero. When 0 the interval grows over time."); "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" DEFINE_int32(stats_per_interval, 0, "Reports additional stats per interval when"
" this is greater than 0."); " this is greater than 0.");
@ -992,6 +995,18 @@ class Stats {
fprintf(stderr, "... finished %" PRIu64 " ops%30s\r", done_, ""); fprintf(stderr, "... finished %" PRIu64 " ops%30s\r", done_, "");
} else { } else {
double now = FLAGS_env->NowMicros(); double now = FLAGS_env->NowMicros();
int64_t usecs_since_last = now - last_report_finish_;
// Determine whether to print status where interval is either
// each N operations or each N seconds.
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, fprintf(stderr,
"%s ... thread %d: (%" PRIu64 ",%" PRIu64 ") ops and " "%s ... thread %d: (%" PRIu64 ",%" PRIu64 ") ops and "
"(%.1f,%.1f) ops/second in (%.6f,%.6f) seconds\n", "(%.1f,%.1f) ops/second in (%.6f,%.6f) seconds\n",
@ -999,7 +1014,7 @@ class Stats {
id_, id_,
done_ - last_report_done_, done_, done_ - last_report_done_, done_,
(done_ - last_report_done_) / (done_ - last_report_done_) /
((now - last_report_finish_) / 1000000.0), (usecs_since_last / 1000000.0),
done_ / ((now - start_) / 1000000.0), done_ / ((now - start_) / 1000000.0),
(now - last_report_finish_) / 1000000.0, (now - last_report_finish_) / 1000000.0,
(now - start_) / 1000000.0); (now - start_) / 1000000.0);
@ -1023,6 +1038,7 @@ class Stats {
last_report_finish_ = now; last_report_finish_ = now;
last_report_done_ = done_; last_report_done_ = done_;
} }
}
if (id_ == 0 && FLAGS_thread_status_per_interval) { if (id_ == 0 && FLAGS_thread_status_per_interval) {
PrintThreadStatus(); PrintThreadStatus();
} }
@ -3389,6 +3405,12 @@ int main(int argc, char** argv) {
FLAGS_db = default_db_path; 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; rocksdb::Benchmark benchmark;
benchmark.Run(); benchmark.Run();
return 0; return 0;

@ -77,7 +77,7 @@ const_params="
\ \
--statistics=1 \ --statistics=1 \
--stats_per_interval=1 \ --stats_per_interval=1 \
--stats_interval=$((1 * M)) \ --stats_interval_seconds=60 \
--histogram=1 \ --histogram=1 \
\ \
--memtablerep=skip_list \ --memtablerep=skip_list \

Loading…
Cancel
Save