From 37159a6448f64fac976a9c96ced440bd6bfb15e0 Mon Sep 17 00:00:00 2001 From: SherlockNoMad Date: Sun, 31 Jan 2016 18:09:24 -0800 Subject: [PATCH] Add histogram for value size per operation --- db/db_impl.cc | 3 +++ include/rocksdb/statistics.h | 7 +++++++ 2 files changed, 10 insertions(+) diff --git a/db/db_impl.cc b/db/db_impl.cc index 2afab389d3..51ed9a3a03 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -3327,6 +3327,7 @@ Status DBImpl::GetImpl(const ReadOptions& read_options, RecordTick(stats_, NUMBER_KEYS_READ); RecordTick(stats_, BYTES_READ, value->size()); + MeasureTime(stats_, BYTES_PER_READ, value->size()); } return s; } @@ -3437,6 +3438,7 @@ std::vector DBImpl::MultiGet( RecordTick(stats_, NUMBER_MULTIGET_CALLS); RecordTick(stats_, NUMBER_MULTIGET_KEYS_READ, num_keys); RecordTick(stats_, NUMBER_MULTIGET_BYTES_READ, bytes_read); + MeasureTime(stats_, BYTES_PER_MULTIGET, bytes_read); PERF_TIMER_STOP(get_post_process_time); return stat_list; @@ -4321,6 +4323,7 @@ Status DBImpl::WriteImpl(const WriteOptions& write_options, // Record statistics RecordTick(stats_, NUMBER_KEYS_WRITTEN, total_count); RecordTick(stats_, BYTES_WRITTEN, total_byte_size); + MeasureTime(stats_, BYTES_PER_WRITE, total_byte_size); PERF_TIMER_STOP(write_pre_and_post_process_time); if (write_options.disableWAL) { diff --git a/include/rocksdb/statistics.h b/include/rocksdb/statistics.h index 813104b997..35de933345 100644 --- a/include/rocksdb/statistics.h +++ b/include/rocksdb/statistics.h @@ -280,6 +280,10 @@ enum Histograms : uint32_t { SST_READ_MICROS, // The number of subcompactions actually scheduled during a compaction NUM_SUBCOMPACTIONS_SCHEDULED, + // Value size distribution in each operation + BYTES_PER_READ, + BYTES_PER_WRITE, + BYTES_PER_MULTIGET, HISTOGRAM_ENUM_MAX, // TODO(ldemailly): enforce HistogramsNameMap match }; @@ -307,6 +311,9 @@ const std::vector> HistogramsNameMap = { {WRITE_STALL, "rocksdb.db.write.stall"}, {SST_READ_MICROS, "rocksdb.sst.read.micros"}, {NUM_SUBCOMPACTIONS_SCHEDULED, "rocksdb.num.subcompactions.scheduled"}, + {BYTES_PER_READ, "rocksdb.bytes.per.read"}, + {BYTES_PER_WRITE, "rocksdb.bytes.per.write"}, + {BYTES_PER_MULTIGET, "rocksdb.bytes.per.multiget"}, }; struct HistogramData {