tud-zih-energy / lo2s

Linux OTF2 Sampling - A Lightweight Node-Level Performance Monitoring Tool
https://tu-dresden.de/zih/forschung/projekte/lo2s?set_language=en
GNU General Public License v3.0
45 stars 13 forks source link

fix(metrics): Prevent NaNs in sampling from occuring #270

Closed cvonelm closed 1 year ago

cvonelm commented 1 year ago

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.

This fixes #267

bmario commented 1 year ago

I don't want to be that picky, but the commit message could need some touches still. But keep that aside for a moment.

What I'm wondering is this:

I don't understand it.

Another thing, does the situation occur that diff_running is zero, but neither diff_enabled nor diff_value is? The current implementation would result in infinity. The current patch would change that to zero. What should be the desired outcome? Why don't we handle the case that diff_running is zero in the first if condition? Hence the outcome would be diff_value.

cvonelm commented 1 year ago

There is forgotten knowledge passed down from the ancients of the SVN galaxy that there might have been a perf bug.

A bug for which there is zero information of it ever existing, neither in kernel changelogs, Robert and Thomas' knowledge and even the ancient scriptures of the lo2s SVN repository. During trial runs of lo2s, it also did not occur.

What should be the desired outcome?

Zero, I think. I don't see a case where a metric that was running 0% of the time during that sample interval should produce something else than diff_value of 0 occurences.

tilsche commented 1 year ago

Is anything blocking this? I kinda need it :/

cvonelm commented 1 year ago

someone should have a final look at the explanatory comment I have included in counter_buffer.hpp to make sure that it doesn't contain obvious bullshit.

Other than that I think we can ship it.