From 6506e42d5720d6d2193a1796674acce09af3689a Mon Sep 17 00:00:00 2001 From: Yang Zhang Date: Thu, 26 Sep 2024 23:31:36 -0700 Subject: [PATCH] Add WAL write metric (#378) Signed-off-by: Wangweizhen Signed-off-by: tabokie Signed-off-by: Yang Zhang Co-authored-by: Weizhen Wang --- 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 df67ba8c8f1..cbe6e8fbd74 100644 --- a/db/db_impl/db_impl_write.cc +++ b/db/db_impl/db_impl_write.cc @@ -1373,6 +1373,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; io_s = status_to_io_status(MergeBatch(write_group, &tmp_batch_, &merged_batch, &write_with_wal, &to_be_cached_state)); @@ -1469,6 +1470,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; io_s = status_to_io_status(MergeBatch(write_group, &tmp_batch, &merged_batch, &write_with_wal, &to_be_cached_state)); diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 9aab337124f..de3052a1f5b 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -636,6 +636,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 cc679ec0a94..d7c9642e8e1 100644 --- a/monitoring/statistics.cc +++ b/monitoring/statistics.cc @@ -327,6 +327,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_SST_READ_PER_LEVEL, "rocksdb.num.sst.read.per.level"},