Skip to content

Commit f8eb364

Browse files
amnonhnyh
authored andcommitted
metrics.cc: Do not merge empty histogram
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 <[email protected]> Closes scylladb#1294
1 parent 6614ac5 commit f8eb364

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

src/core/metrics.cc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -376,6 +376,9 @@ const bool metric_disabled = false;
376376

377377

378378
histogram& histogram::operator+=(const histogram& c) {
379+
if (c.sample_count == 0) {
380+
return *this;
381+
}
379382
for (size_t i = 0; i < c.buckets.size(); i++) {
380383
if (buckets.size() <= i) {
381384
buckets.push_back(c.buckets[i]);

0 commit comments

Comments
 (0)