diff --git a/db/memtable.cc b/db/memtable.cc index bc4062ac67..4678e6adf9 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 18c186a950..ac9ef79771 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 e898565131..dfc818e8b7 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)