[Rocksdb] Measure all FSYNC/SYNC times

Summary: Add stop watches around all sync calls.

Test Plan: db_bench check if respective histograms are printed

Reviewers: haobo, dhruba

Reviewed By: haobo

CC: leveldb

Differential Revision: https://reviews.facebook.net/D11073
main
Abhishek Kona 11 years ago
parent ee522d0032
commit d91b42ee27
  1. 3
      db/builder.cc
  2. 6
      db/db_bench.cc
  3. 4
      db/db_impl.cc
  4. 3
      db/version_set.cc
  5. 7
      include/leveldb/statistics.h

@ -12,6 +12,7 @@
#include "leveldb/db.h"
#include "leveldb/env.h"
#include "leveldb/iterator.h"
#include "util/stop_watch.h"
namespace leveldb {
@ -147,8 +148,10 @@ Status BuildTable(const std::string& dbname,
// Finish and check for file errors
if (s.ok() && !options.disableDataSync) {
if (options.use_fsync) {
StopWatch sw(env, options.statistics, TABLE_SYNC_MICROS);
s = file->Fsync();
} else {
StopWatch sw(env, options.statistics, TABLE_SYNC_MICROS);
s = file->Sync();
}
}

@ -736,6 +736,12 @@ class Benchmark {
PrintHistogram(DB_GET, "DB_GET");
PrintHistogram(DB_WRITE, "DB_WRITE");
PrintHistogram(COMPACTION_TIME, "COMPACTION_TIME");
PrintHistogram(TABLE_SYNC_MICROS, "TABLE SYNC MICROS");
PrintHistogram(
COMPACTION_OUTFILE_SYNC_MICROS,
"COMPACTION OUT FILE SYNC MICROS");
PrintHistogram(WAL_FILE_SYNC_MICROS, "WAL FILE SYNC MICROS");
PrintHistogram(MANIFEST_FILE_SYNC_MICROS, "Manifest SYNC MICROS");
}
}

@ -1523,8 +1523,10 @@ Status DBImpl::FinishCompactionOutputFile(CompactionState* compact,
// Finish and check for file errors
if (s.ok() && !options_.disableDataSync) {
if (options_.use_fsync) {
StopWatch sw(env_, options_.statistics, COMPACTION_OUTFILE_SYNC_MICROS);
s = compact->outfile->Fsync();
} else {
StopWatch sw(env_, options_.statistics, COMPACTION_OUTFILE_SYNC_MICROS);
s = compact->outfile->Sync();
}
}
@ -2128,8 +2130,10 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) {
status = log_->AddRecord(WriteBatchInternal::Contents(updates));
if (status.ok() && options.sync) {
if (options_.use_fsync) {
StopWatch(env_, options_.statistics, WAL_FILE_SYNC_MICROS);
status = log_->file()->Fsync();
} else {
StopWatch(env_, options_.statistics, WAL_FILE_SYNC_MICROS);
status = log_->file()->Sync();
}
}

@ -18,6 +18,7 @@
#include "table/two_level_iterator.h"
#include "util/coding.h"
#include "util/logging.h"
#include "util/stop_watch.h"
namespace leveldb {
@ -1123,8 +1124,10 @@ Status VersionSet::LogAndApply(VersionEdit* edit, port::Mutex* mu,
}
if (s.ok()) {
if (options_->use_fsync) {
StopWatch sw(env_, options_->statistics, MANIFEST_FILE_SYNC_MICROS);
s = descriptor_log_->file()->Fsync();
} else {
StopWatch sw(env_, options_->statistics, MANIFEST_FILE_SYNC_MICROS);
s = descriptor_log_->file()->Sync();
}
}

@ -62,7 +62,12 @@ enum Histograms {
DB_GET = 0,
DB_WRITE = 1,
COMPACTION_TIME = 2,
HISTOGRAM_ENUM_MAX = 3,
TABLE_SYNC_MICROS = 3,
COMPACTION_OUTFILE_SYNC_MICROS = 4,
WAL_FILE_SYNC_MICROS = 5,
MANIFEST_FILE_SYNC_MICROS = 6,
HISTOGRAM_ENUM_MAX = 7
};
struct HistogramData {

Loading…
Cancel
Save