nhancdt2602 commented on code in PR #3557:
URL: https://github.com/apache/kvrocks/pull/3557#discussion_r3577059846
##########
src/server/server.cc:
##########
@@ -872,7 +858,18 @@ uint64_t Server::GetClientID() { return
client_id_.fetch_add(1, std::memory_orde
void Server::recordInstantaneousMetrics() {
auto rocksdb_stats = storage->GetDB()->GetDBOptions().statistics;
- stats.TrackInstantaneousMetric(STATS_METRIC_COMMAND, stats.total_calls);
+ // Sample each namespace's command metric, and feed the sum into the global
metric so the
+ // admin/default view reports aggregate ops/sec without keeping a global
command counter on the hot path.
+ uint64_t total_calls = 0;
+ {
+ std::shared_lock<std::shared_mutex> lock(ns_stats_mu_);
+ for (const auto &[ns, ns_stats] : ns_stats_) {
+ auto calls = ns_stats->total_calls.load();
+ ns_stats->TrackInstantaneousMetric(STATS_METRIC_COMMAND, calls);
+ total_calls += calls;
+ }
+ }
+ stats.TrackInstantaneousMetric(STATS_METRIC_COMMAND, total_calls);
Review Comment:
As this method is not called too frequently, I believe the overhead is
acceptable.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]