promql: Fix issue where summation of +/- infinity returns NaN instead of infinity#14362
Merged
codesome merged 1 commit intoprometheus:mainfrom Jul 3, 2024
Merged
Conversation
166a10b to
0d48405
Compare
…nity Signed-off-by: Charles Korn <charles.korn@grafana.com>
0d48405 to
fd6bdf5
Compare
codesome
approved these changes
Jun 30, 2024
codesome
requested changes
Jun 30, 2024
Member
codesome
left a comment
There was a problem hiding this comment.
Just 1 nit: Can we put the test inside functions_test.go? It is a small file and we can add a comment to the test saying why we are testing it separately.
Contributor
Author
That was my original intention, but
|
codesome
approved these changes
Jul 3, 2024
jhesketh
added a commit
to jhesketh/mimir
that referenced
this pull request
Aug 7, 2024
Implements the improvements from prometheus/prometheus#14074 prometheus/prometheus#14362
4 tasks
jhesketh
added a commit
to grafana/mimir
that referenced
this pull request
Aug 7, 2024
* MQE: Use kahan in sum aggregation Implements the improvements from prometheus/prometheus#14074 prometheus/prometheus#14362 * Update CHANGELOG
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This fixes an issue with
kahanSumIncwhich would result in NaN being used as the final result when +Inf or -Inf was one of the values added.I've expanded the test coverage of
kahanSumIncto cover these cases and others involving NaN.This does now mean that
kahanSumIncdoes an extra check for Inf at each step. An alternative to this would be to check for +Inf or -Inf when computing the final result (ie. after all the calls tokahanSumInc), but I opted for this as the simplest, least invasive change given how widelykahanSumIncis used.This also revealed what I believe was an incorrect test case in
promql/promqltest/testdata/native_histograms.test, where the stddev and stdvar were incorrectly calculated when a native histogram contained a sample at +Inf.