From d38e497642457df03167758b3f9075e2d9f187f5 Mon Sep 17 00:00:00 2001 From: Weizhen Wang Date: Mon, 9 Mar 2020 14:14:52 +0800 Subject: [PATCH] Add WAL write duration metric (#153) Add WAL write duration metric UCP tikv/tikv#6541 Signed-off-by: Wangweizhen Signed-off-by: tabokie --- db/db_impl/db_impl_write.cc | 2 ++ include/rocksdb/statistics.h | 1 + monitoring/statistics.cc | 1 + 3 files changed, 4 insertions(+) diff --git a/db/db_impl/db_impl_write.cc b/db/db_impl/db_impl_write.cc index 5ef279338bf..09ce9943b2f 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -1139,6 +1139,7 @@ IOStatus DBImpl::WriteToWAL(const WriteThread::WriteGroup& write_group, // Same holds for all in the batch group size_t write_with_wal = 0; WriteBatch* to_be_cached_state = nullptr; + StopWatch write_sw(immutable_db_options_.clock, stats_, DB_WRITE_WAL_TIME); WriteBatch* merged_batch = MergeBatch(write_group, &tmp_batch_, &write_with_wal, &to_be_cached_state); if (merged_batch == write_group.leader->batch) { @@ -1228,6 +1229,7 @@ IOStatus DBImpl::ConcurrentWriteToWAL( WriteBatch tmp_batch; size_t write_with_wal = 0; WriteBatch* to_be_cached_state = nullptr; + StopWatch write_sw(immutable_db_options_.clock, stats_, DB_WRITE_WAL_TIME); WriteBatch* merged_batch = MergeBatch(write_group, &tmp_batch, &write_with_wal, &to_be_cached_state); diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 75a55622962..36cc6d560b1 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -516,6 +516,7 @@ enum Histograms : uint32_t { // Time spent flushing memtable to disk FLUSH_TIME, SST_BATCH_SIZE, + DB_WRITE_WAL_TIME, // MultiGet stats logged per level // Num of index and filter blocks read from file system per level. diff --git a/monitoring/statistics.cc b/monitoring/statistics.cc index 9930f1ea980..1ef3fa79235 100644 --- a/monitoring/statistics.cc +++ b/monitoring/statistics.cc @@ -274,6 +274,7 @@ const std::vector> HistogramsNameMap = { {BLOB_DB_DECOMPRESSION_MICROS, "rocksdb.blobdb.decompression.micros"}, {FLUSH_TIME, "rocksdb.db.flush.micros"}, {SST_BATCH_SIZE, "rocksdb.sst.batch.size"}, + {DB_WRITE_WAL_TIME, "rocksdb.db.write.wal.time"}, {NUM_INDEX_AND_FILTER_BLOCKS_READ_PER_LEVEL, "rocksdb.num.index.and.filter.blocks.read.per.level"}, {NUM_DATA_BLOCKS_READ_PER_LEVEL, "rocksdb.num.data.blocks.read.per.level"},