mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2024-12-15 00:13:30 +01:00
vmselect/rollup: rm workaround for slow-changing counters (#3163)
The workaround was introduced to fix https://github.com/VictoriaMetrics/VictoriaMetrics/issues/962. However, it didn't prove itself useful. Instead, it is recommended using `increase_pure` function. Removing the workaround makes VM to produce accurate results when calculating `delta` or `increase` functions over slow-changing counters with vary intervals between data points. Signed-off-by: hagen1778 <roman@victoriametrics.com> Signed-off-by: hagen1778 <roman@victoriametrics.com>
This commit is contained in:
parent
2b98f2bc1a
commit
4acbf6e7d4
@ -1495,11 +1495,8 @@ func rollupDelta(rfa *rollupFuncArg) float64 {
|
|||||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/894
|
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/894
|
||||||
return values[len(values)-1] - rfa.realPrevValue
|
return values[len(values)-1] - rfa.realPrevValue
|
||||||
}
|
}
|
||||||
// Assume that the previous non-existing value was 0 only in the following cases:
|
// Assume that the previous non-existing value was 0
|
||||||
//
|
// only if the first value doesn't exceed too much the delta with the next value.
|
||||||
// - If the delta with the next value equals to 0.
|
|
||||||
// This is the case for slow-changing counter - see https://github.com/VictoriaMetrics/VictoriaMetrics/issues/962
|
|
||||||
// - If the first value doesn't exceed too much the delta with the next value.
|
|
||||||
//
|
//
|
||||||
// This should prevent from improper increase() results for os-level counters
|
// This should prevent from improper increase() results for os-level counters
|
||||||
// such as cpu time or bytes sent over the network interface.
|
// such as cpu time or bytes sent over the network interface.
|
||||||
@ -1513,9 +1510,6 @@ func rollupDelta(rfa *rollupFuncArg) float64 {
|
|||||||
} else if !math.IsNaN(rfa.realNextValue) {
|
} else if !math.IsNaN(rfa.realNextValue) {
|
||||||
d = rfa.realNextValue - values[0]
|
d = rfa.realNextValue - values[0]
|
||||||
}
|
}
|
||||||
if d == 0 {
|
|
||||||
d = 10
|
|
||||||
}
|
|
||||||
if math.Abs(values[0]) < 10*(math.Abs(d)+1) {
|
if math.Abs(values[0]) < 10*(math.Abs(d)+1) {
|
||||||
prevValue = 0
|
prevValue = 0
|
||||||
} else {
|
} else {
|
||||||
|
@ -1425,19 +1425,16 @@ func TestRollupDelta(t *testing.T) {
|
|||||||
|
|
||||||
// Small initial value
|
// Small initial value
|
||||||
f(nan, nan, nan, []float64{1}, 1)
|
f(nan, nan, nan, []float64{1}, 1)
|
||||||
f(nan, nan, nan, []float64{10}, 10)
|
f(nan, nan, nan, []float64{10}, 0)
|
||||||
f(nan, nan, nan, []float64{100}, 100)
|
f(nan, nan, nan, []float64{100}, 0)
|
||||||
f(nan, nan, nan, []float64{1, 2, 3}, 3)
|
f(nan, nan, nan, []float64{1, 2, 3}, 3)
|
||||||
f(1, nan, nan, []float64{1, 2, 3}, 2)
|
f(1, nan, nan, []float64{1, 2, 3}, 2)
|
||||||
f(nan, nan, nan, []float64{5, 6, 8}, 8)
|
f(nan, nan, nan, []float64{5, 6, 8}, 8)
|
||||||
f(2, nan, nan, []float64{5, 6, 8}, 6)
|
f(2, nan, nan, []float64{5, 6, 8}, 6)
|
||||||
|
|
||||||
// Moderate initial value with zero delta after that.
|
f(nan, nan, nan, []float64{100, 100}, 0)
|
||||||
// See https://github.com/VictoriaMetrics/VictoriaMetrics/issues/962
|
|
||||||
f(nan, nan, nan, []float64{100}, 100)
|
|
||||||
f(nan, nan, nan, []float64{100, 100}, 100)
|
|
||||||
|
|
||||||
// Big initial value with with zero delta after that.
|
// Big initial value with zero delta after that.
|
||||||
f(nan, nan, nan, []float64{1000}, 0)
|
f(nan, nan, nan, []float64{1000}, 0)
|
||||||
f(nan, nan, nan, []float64{1000, 1000}, 0)
|
f(nan, nan, nan, []float64{1000, 1000}, 0)
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user