Skip to content

Commit

Permalink
fix(metrics): Prevent NaNs in sampling from occuring
Browse files Browse the repository at this point in the history
A code path could lead to a NaN if diff_running is 0 as this would
result in  a division-by-zero.

This commit solves this problem by just deleting that code path, as
there is no evidence that the bug it addresses has existed in recent
times, if ever.
  • Loading branch information
cvonelm committed Apr 6, 2023
1 parent d1c8d44 commit cbda419
Showing 1 changed file with 0 additions and 7 deletions.
7 changes: 0 additions & 7 deletions include/lo2s/perf/counter/counter_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -73,13 +73,6 @@ class CounterBuffer
{
accumulated_[i] += diff_value;
}
// Due to a perf bug diff_enabled and diff_running may be swapped
// diff_enabled is always smaller than diff_running so swap them if diff_enabled >
// diff_running
else if (diff_enabled > diff_running)
{
accumulated_[i] += (static_cast<double>(diff_enabled) / diff_running) * diff_value;
}
else
{
accumulated_[i] += (static_cast<double>(diff_running) / diff_enabled) * diff_value;
Expand Down

0 comments on commit cbda419

Please sign in to comment.