From 3cf7f353d9ccf5e9af73da6c73f087ff55036674 Mon Sep 17 00:00:00 2001 From: Igor Canadi Date: Fri, 27 Feb 2015 17:06:06 -0800 Subject: [PATCH] Instrument memtable seeks Summary: As title Test Plan: compiles Reviewers: sdong Reviewed By: sdong Subscribers: dhruba, leveldb Differential Revision: https://reviews.facebook.net/D34191 --- db/memtable.cc | 2 ++ include/rocksdb/perf_context.h | 4 ++++ util/perf_context.cc | 4 ++++ 3 files changed, 10 insertions(+) diff --git a/db/memtable.cc b/db/memtable.cc index bc4062ac6..4678e6adf 100644 --- a/db/memtable.cc +++ b/db/memtable.cc @@ -223,6 +223,8 @@ class MemTableIterator: public Iterator { virtual bool Valid() const override { return valid_; } virtual void Seek(const Slice& k) override { + PERF_TIMER_GUARD(seek_on_memtable_time); + PERF_COUNTER_ADD(seek_on_memtable_count, 1); if (bloom_ != nullptr && !bloom_->MayContain(prefix_extractor_->Transform(ExtractUserKey(k)))) { valid_ = false; diff --git a/include/rocksdb/perf_context.h b/include/rocksdb/perf_context.h index 18c186a95..ac9ef7977 100644 --- a/include/rocksdb/perf_context.h +++ b/include/rocksdb/perf_context.h @@ -51,6 +51,10 @@ struct PerfContext { // total time spent after Get() finds a key uint64_t get_post_process_time; uint64_t get_from_output_files_time; // total time reading from output files + // total time spent on seeking memtable + uint64_t seek_on_memtable_time; + // number of seeks issued on memtable + uint64_t seek_on_memtable_count; // total time spent on seeking child iters uint64_t seek_child_seek_time; // number of seek issued in child iterators diff --git a/util/perf_context.cc b/util/perf_context.cc index e89856513..dfc818e8b 100644 --- a/util/perf_context.cc +++ b/util/perf_context.cc @@ -44,6 +44,8 @@ void PerfContext::Reset() { get_from_memtable_count = 0; get_post_process_time = 0; get_from_output_files_time = 0; + seek_on_memtable_time = 0; + seek_on_memtable_count = 0; seek_child_seek_time = 0; seek_child_seek_count = 0; seek_min_heap_time = 0; @@ -78,6 +80,8 @@ std::string PerfContext::ToString() const { << OUTPUT(get_from_memtable_count) << OUTPUT(get_post_process_time) << OUTPUT(get_from_output_files_time) + << OUTPUT(seek_on_memtable_time) + << OUTPUT(seek_on_memtable_count) << OUTPUT(seek_child_seek_time) << OUTPUT(seek_child_seek_count) << OUTPUT(seek_min_heap_time)