From ec77366e14dfcef610d4d9f39cbfaeabe2fe8289 Mon Sep 17 00:00:00 2001 From: Abhishek Kona Date: Wed, 20 Feb 2013 19:22:13 -0800 Subject: [PATCH] Counters for bytes written and read. Summary: * Counters for bytes read and write. as a part of this diff, I want to=> * Measure compaction times. @dhruba can you point which function, should * I time to get Compaction-times. Was looking at CompactRange. Test Plan: db_test Reviewers: dhruba, emayanke CC: leveldb Differential Revision: https://reviews.facebook.net/D8763 --- db/db_impl.cc | 7 +++++-- include/leveldb/statistics.h | 6 +++++- 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/db/db_impl.cc b/db/db_impl.cc index 4e6853e3e..dfa6f8634 100644 --- a/db/db_impl.cc +++ b/db/db_impl.cc @@ -1650,7 +1650,7 @@ Status DBImpl::DoCompactionWork(CompactionState* compact) { assert(ikey.type != kTypeDeletion); UpdateInternalKey(key, (uint64_t)0, ikey.type); } - + // Open output file if necessary if (compact->builder == nullptr) { status = OpenCompactionOutputFile(compact); @@ -1855,6 +1855,7 @@ Status DBImpl::Get(const ReadOptions& options, imm.UnrefAll(); current->Unref(); RecordTick(options_.statistics, NUMBER_KEYS_READ); + RecordTick(options_.statistics, BYTES_READ, value->size()); return s; } @@ -1917,7 +1918,9 @@ Status DBImpl::Write(const WriteOptions& options, WriteBatch* my_batch) { last_sequence += my_batch_count; // Record statistics RecordTick(options_.statistics, NUMBER_KEYS_WRITTEN, my_batch_count); - + RecordTick(options_.statistics, + BYTES_WRITTEN, + WriteBatchInternal::ByteSize(updates)); // Add to log and apply to memtable. We can release the lock // during this phase since &w is currently responsible for logging // and protects against concurrent loggers and concurrent writes diff --git a/include/leveldb/statistics.h b/include/leveldb/statistics.h index dbdfb7225..8e47b538d 100644 --- a/include/leveldb/statistics.h +++ b/include/leveldb/statistics.h @@ -33,9 +33,13 @@ enum Tickers { NUMBER_KEYS_WRITTEN = 6, // Number of Keys read, NUMBER_KEYS_READ = 7, - TICKER_ENUM_MAX = 8, + // Bytes written / read + BYTES_WRITTEN = 8, + BYTES_READ = 9, + TICKER_ENUM_MAX = 10, }; + /** * Keep adding histogram's here. * Any histogram whould have value less than HISTOGRAM_ENUM_MAX -- GitLab