Repository navigation
promql: preserve equal values during quantile interpolation - #20180
Conversation
|
|
||
| ## main / unreleased | ||
|
|
||
| - [BUGFIX] PromQL: Preserve equal subnormal samples during quantile interpolation, including the median used by `mad_over_time`. |
There was a problem hiding this comment.
CHANGELOG.md is generated at release time from PR release-notes blocks via scripts/generate_release_notes.sh, so please revert the direct edit here to avoid merge conflicts and duplicate entries.
There was a problem hiding this comment.
PR head: 0b49224f29628d487d187468c39e5a808f768ca4. Response to this feedback.
Removed the direct CHANGELOG.md edit; the PR release-notes block remains for release generation.
Signed-off-by: Perfloop Agent <[email protected]>
8f74c64 to
0b49224
Compare
Which issue(s) does the PR fix:The shared
The standalone comparison program used for the base/final assertion is not included in this pull request. The 32-bit This condition holds with this change and does not hold at Release notes for end users (ALL commits must be considered).Generated by Perfloop. |
…7444) #### What this PR does Ports prometheus/prometheus#20180 to MQE. That change is already in the vendored Prometheus, so since the last vendoring the two engines can return different values for `quantile`, `quantile_over_time` and `mad_over_time` when the quantile falls between two identical values. When the quantile falls between two samples, both engines interpolate with `lower*(1-weight) + upper*weight`. If the two samples are identical, this can return a value that differs from the samples by a rounding error, for example `quantile_over_time(0.3, ...)` over two samples of `0.1` returns `0.09999999999999999`, or `0` for very small (subnormal) values because of underflow. The Prometheus engine now returns the sample value in this case, and MQE now does the same. The bits are compared so that negative zero is kept. `TestQuantile` now has the cases from the upstream change, and a case with a rounding error for ordinary values. The comparison compares bits, because `require.Equal` treats negative and positive zero as equal. #### Which issue(s) this PR fixes or relates to Related to prometheus/prometheus#20180 #### Checklist - [x] Tests updated. - [ ] Documentation added. - [x] `CHANGELOG.md` updated - the order of entries should be `[CHANGE]`, `[FEATURE]`, `[ENHANCEMENT]`, `[BUGFIX]`. If changelog entry is not needed, please add the `changelog-not-needed` label to the PR. - [ ] [`about-versioning.md`](https://github.com/grafana/mimir/blob/main/docs/sources/mimir/configure/about-versioning.md) updated with experimental features.
Note
Triggered and guided by @bwplotka -- let me know if this is too spammy etc!
Which issue(s) does the PR fix:
The shared quantile helper now returns an identical sample directly instead of multiplying it by interpolation weights. This preserves subnormal values in
quantile_over_timeand quantile aggregation while leaving unequal endpoints on the existing weighted formula.mad_over_timeuses the same helper for its median.TestQuantileInterpolationPreservesExactValuesruns both query operations against TSDB data and compares float64 bits, including non-finite, signed-zero, invalid-q, and unequal-endpoint controls. It fails at the base becausequantile_over_time(0.5, ...)returns zero for the smallest positive subnormal; it passes with this change.TestMADOverTimeUsesExactSubnormalMedianchecks the other shared consumer: at base it returns one subnormal unit instead of two, and it passes with this change.A small Go program used for the base/final correctness assertion is not included in this pull request. The full
go test -count=1 ./promqlpassed on the final source.The 32-bit Go test job (
GOARCH=386 go test -parallel=1 ./...) did not run locally; itsgithub.com/prometheus/prometheus/promqltests remain target-CI work because this sandbox cannot execute 32-bit ELF binaries.This condition holds with this change and does not hold at
a2fda0ef4638518a6a6fb27fc48be88fbd732f4b:For the specified two-sample constant finite inputs, both `quantile_over_time` and quantile aggregation return the exact input float64 bits for both signs of the smallest subnormal, three subnormal units, largest subnormal, and smallest normal at q=0.25, 0.5, and 0.75; `mad_over_time` returns two smallest-subnormal units for `[0, 3, 3, 6]`; mixed signed zero returns +0, equal infinities retain their sign, mixed infinities and NaN samples return NaN, and q=NaN, -1, and 2 return NaN, -Inf, and +Inf respectively with invalid-quantile warnings; opposite MaxFloat64 endpoints return +0, and adjacent endpoints near MaxFloat64 remain finite..Release notes for end users (ALL commits must be considered).
Generated by Perfloop.