From 734ebccc7733cd14db06802237ddfe73e017df76 Mon Sep 17 00:00:00 2001 From: Clive Unger Date: Tue, 22 Jun 2021 14:32:15 -0500 Subject: [PATCH 1/3] Modify StepFit metric to be RMSE --- perf/go/stepfit/stepfit.go | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/perf/go/stepfit/stepfit.go b/perf/go/stepfit/stepfit.go index 4f6150bef77..1e64d73b27a 100644 --- a/perf/go/stepfit/stepfit.go +++ b/perf/go/stepfit/stepfit.go @@ -120,9 +120,8 @@ func GetStepFitAtMid(trace []float32, stddevThreshold float32, interesting float stepSize = (y0 - y1) } } - // The next line of code should actually be math.Sqrt(lse/len(trace)) - // instead it is math.Sqrt(lse)/len(trace), which does not give the stddev. - lse = float32(math.Sqrt(float64(lse))) / float32(len(trace)) + // Calculate the Root-Mean-Squared Error to measure fit to step function + lse = float32(math.Sqrt(float64(lse) / float64(len(trace))) if lse < stddevThreshold { regression = stepSize / stddevThreshold } else { From 95e8bec0456d10f4bbcbf0f96262c4a828a55a59 Mon Sep 17 00:00:00 2001 From: Clive Unger Date: Thu, 24 Jun 2021 18:43:54 -0500 Subject: [PATCH 2/3] Revert "Modify StepFit metric to be RMSE" This reverts commit 734ebccc7733cd14db06802237ddfe73e017df76. --- perf/go/stepfit/stepfit.go | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/perf/go/stepfit/stepfit.go b/perf/go/stepfit/stepfit.go index 1e64d73b27a..4f6150bef77 100644 --- a/perf/go/stepfit/stepfit.go +++ b/perf/go/stepfit/stepfit.go @@ -120,8 +120,9 @@ func GetStepFitAtMid(trace []float32, stddevThreshold float32, interesting float stepSize = (y0 - y1) } } - // Calculate the Root-Mean-Squared Error to measure fit to step function - lse = float32(math.Sqrt(float64(lse) / float64(len(trace))) + // The next line of code should actually be math.Sqrt(lse/len(trace)) + // instead it is math.Sqrt(lse)/len(trace), which does not give the stddev. + lse = float32(math.Sqrt(float64(lse))) / float32(len(trace)) if lse < stddevThreshold { regression = stepSize / stddevThreshold } else { From eb77046af9eb899aee22501152190e0a2fcd9aad Mon Sep 17 00:00:00 2001 From: Clive Unger Date: Thu, 24 Jun 2021 19:03:34 -0500 Subject: [PATCH 3/3] Add "RatioStep" detection based on OriginalStep --- perf/go/stepfit/stepfit.go | 18 ++++++++++++++++++ perf/go/types/types.go | 4 ++++ 2 files changed, 22 insertions(+) diff --git a/perf/go/stepfit/stepfit.go b/perf/go/stepfit/stepfit.go index 4f6150bef77..3b2598fef0c 100644 --- a/perf/go/stepfit/stepfit.go +++ b/perf/go/stepfit/stepfit.go @@ -174,6 +174,24 @@ func GetStepFitAtMid(trace []float32, stddevThreshold float32, interesting float } regression = stepSize } + } else if stepDetection == types.RatioStep { + // This is a modified version of Original Step, which uses + // Root-Mean-Squared Error to calculate the fitness. + lse = float32(math.MaxFloat32) + if y0 != y1 { + d := vec32.SSE(trace[:i], y0) + vec32.SSE(trace[i:], y1) + if d < lse { + lse = d + stepSize = (y0 - y1) + } + } + // Calculate the Root-Mean-Squared Error to measure fit to step function + lse = float32(math.Sqrt(float64(lse) / float64(len(trace)))) + if lse < stddevThreshold { + regression = stepSize / stddevThreshold + } else { + regression = stepSize / lse + } } else /* types.MannWhitneyU */ { s1 := vec32.ToFloat64(trace[:i]) s2 := vec32.ToFloat64(trace[i:]) diff --git a/perf/go/types/types.go b/perf/go/types/types.go index 4d637d7311b..88a1fa49e2c 100644 --- a/perf/go/types/types.go +++ b/perf/go/types/types.go @@ -96,6 +96,10 @@ const ( // empty string so we pick up the right default from old alerts. OriginalStep StepDetection = "" + // RatioStep is exactly like OriginalStep except it uses RMSE as the + // fitness function to calculate the regression ratio. + RatioStep StepDetection = "ratio" + // AbsoluteStep is a step detection that looks for an absolute magnitude // change. AbsoluteStep StepDetection = "absolute"