Skip to content

Commit

Permalink
metrics.cc: Do not merge empty histogram
Browse files Browse the repository at this point in the history
It is common to have empty histograms. This patch adds an optimization
when merging an empty histogram to another histogram to return early.

Signed-off-by: Amnon Heiman <amnon@scylladb.com>

Closes scylladb#1294
  • Loading branch information
amnonh authored and nyh committed Nov 14, 2022
1 parent 6614ac5 commit f8eb364
Showing 1 changed file with 3 additions and 0 deletions.
3 changes: 3 additions & 0 deletions src/core/metrics.cc
Original file line number Diff line number Diff line change
Expand Up @@ -376,6 +376,9 @@ const bool metric_disabled = false;


histogram& histogram::operator+=(const histogram& c) {
if (c.sample_count == 0) {
return *this;
}
for (size_t i = 0; i < c.buckets.size(); i++) {
if (buckets.size() <= i) {
buckets.push_back(c.buckets[i]);
Expand Down

0 comments on commit f8eb364

Please sign in to comment.