From 358499f8688480ad2d118a644f801f3e773f73e3 Mon Sep 17 00:00:00 2001 From: Bryan Boreham Date: Sat, 19 Jul 2025 15:19:29 +0100 Subject: [PATCH] [BUGFIX] PromQL: Noinline kahanSum, to avoid compiler optimisations Observed on go1.24.4 darwin/arm64, the compensation variable is not correctly calculated. Note you may have to run the tests several times to see it, to get the right ordering of series. Signed-off-by: Bryan Boreham --- promql/functions.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/promql/functions.go b/promql/functions.go index 2577e7f27b..b2af9b501c 100644 --- a/promql/functions.go +++ b/promql/functions.go @@ -1188,6 +1188,9 @@ func funcTimestamp(vals []parser.Value, _ parser.Expressions, enh *EvalNodeHelpe return enh.Out, nil } +// We get incorrect results if this function is inlined; see https://github.com/prometheus/prometheus/issues/16714. +// +//go:noinline func kahanSumInc(inc, sum, c float64) (newSum, newC float64) { t := sum + inc switch {