From 05fcacdb425230f458a3b273de3abecc70dbdea0 Mon Sep 17 00:00:00 2001 From: Ignat Loskutov Date: Thu, 8 Jun 2023 17:40:56 -0700 Subject: [PATCH] Add missing stopwatch and perf timer to DBImplReadOnly (#11521) Summary: The `rocksdb.db.get.micros` histogram is never updated if the DB is open in ReadOnly mode, as well as the `get_cpu_nanos` perf counter. An earlier PR (https://github.com/facebook/rocksdb/issues/4260) for some reason has only added the TODO line, not the accounting itself, so this one is intended to fix it, adding two lines to match [DBImplSecondary](https://github.com/facebook/rocksdb/blob/4dafa5b220c439b7f05eb598a2ab32b3152bedb5/db/db_impl/db_impl_secondary.cc#L366-L367). Pull Request resolved: https://github.com/facebook/rocksdb/pull/11521 Reviewed By: cbi42 Differential Revision: D46577330 Pulled By: jowlyzhang fbshipit-source-id: be147923e763af32bbc18fd6bdf3aff8ebf08aee --- db/db_impl/db_impl_readonly.cc | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/db/db_impl/db_impl_readonly.cc b/db/db_impl/db_impl_readonly.cc index 871cf8085..6f7e95fa7 100644 --- a/db/db_impl/db_impl_readonly.cc +++ b/db/db_impl/db_impl_readonly.cc @@ -46,7 +46,8 @@ Status DBImplReadOnly::Get(const ReadOptions& read_options, "`Env::IOActivity::kUnknown`"); } assert(pinnable_val != nullptr); - // TODO: stopwatch DB_GET needed?, perf timer needed? + PERF_CPU_TIMER_GUARD(get_cpu_nanos, immutable_db_options_.clock); + StopWatch sw(immutable_db_options_.clock, stats_, DB_GET); PERF_TIMER_GUARD(get_snapshot_time); assert(column_family);