-
Notifications
You must be signed in to change notification settings - Fork 9.7k
promql: Re-introduce direct mean calculation #16773
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, but I'm not super familiar with the subject, suggest another pair of eyes
Cleaned up the commits. |
@charleskorn might be a suitable reviewer. (His findings triggered ultimately triggered this.) |
Can you summarise what the net difference of #16569 and this PR is, besides adding tests? |
I did that in the commit description:
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM modulo suggestion for another test case.
Thanks for fixing this @beorn7.
These demonstrate that direct mean calculation has some merits after all. Signed-off-by: beorn7 <beorn@grafana.com>
The test in question actually worked fine even before #16569. The finding reported in the comment has turned out to be caused by something else. Signed-off-by: beorn7 <beorn@grafana.com>
This commit brings back direct mean calculation (for `avg` and `avg_over_time`) but isn't an outright revert of #16569. It keeps the improved incremental mean calculation and features generally a bit cleaner code than before. Also, this commit... - ...updates the lengthy comment explaining the whole situation and trade-offs. - ...divides the running sum and the Kahan compensation term separately (in direct mean calculation) to avoid the (unlikely) possibility that sum and Kahan compensation together ovorflow float64. - ...uncomments the tests that should now work again on darwin/arm64. - ...uncomments the test that should now reliably yield the (inaccurate) value 0 on all hardware platforms. Also, the test description has been updated accordingly. - ...adds avg_over_time tests for zero and one sample in the range. Signed-off-by: beorn7 <beorn@grafana.com>
Thanks. I'll merge on green. |
Signed-off-by: Aleksandr Smirnov <5targazer@mail.ru>
See commit description for details, also the discussion in #16714 .
(The very short version is that I was wrong assuming that the incremental mean calculation combined with Kahan summation in the improved way introduced in #16569 is always at least as good as the previous approach.)
/cc @charleskorn @crush-on-anechka