From 96546aceffcf9f774c2f704a3f8348930a66b4cb Mon Sep 17 00:00:00 2001 From: Aleksandr Nogikh Date: Tue, 22 Aug 2023 12:51:02 +0200 Subject: dashboard/app: calculate obsoletion periods differently Rely on the Poisson distribution to determine the moment when we should give on a bug. We don't have to wait 100x the average time between the crashes. --- dashboard/app/reporting.go | 20 ++++++++++++++++---- 1 file changed, 16 insertions(+), 4 deletions(-) (limited to 'dashboard/app/reporting.go') diff --git a/dashboard/app/reporting.go b/dashboard/app/reporting.go index 3917adb56..27b1fed0b 100644 --- a/dashboard/app/reporting.go +++ b/dashboard/app/reporting.go @@ -7,6 +7,7 @@ import ( "bytes" "encoding/json" "fmt" + "math" "reflect" "sort" "strings" @@ -346,13 +347,24 @@ func (bug *Bug) obsoletePeriod() time.Duration { if config.Obsoleting.MinPeriod == 0 { return period } + + // Let's assume that crashes follow the Possion distribution with rate r=crashes/days. + // Then, the chance of seeing a crash within t days is p=1-e^(-r*t). + // Solving it for t, we get t=log(1/(1-p))/r. + // Since our rate is also only an estimate, let's require p=0.99. + // Before we have at least 10 crashes, any estimation of frequency is too imprecise. // In such case we conservatively assume it still happens. if bug.NumCrashes >= 10 { - // This is linear extrapolation for when the next crash should happen. - period = bug.LastTime.Sub(bug.FirstTime) / time.Duration(bug.NumCrashes-1) - // Let's be conservative with obsoleting too early. - period *= 100 + bugDays := bug.LastTime.Sub(bug.FirstTime).Hours() / 24.0 + rate := float64(bug.NumCrashes-1) / bugDays + + const probability = 0.99 + // For 1 crash/day, this will be ~4.6 days. + days := math.Log(1.0/(1.0-probability)) / rate + // Let's be conservative and multiply it by 3. + days = days * 3 + period = time.Hour * time.Duration(24*days) } min, max := config.Obsoleting.MinPeriod, config.Obsoleting.MaxPeriod if config.Obsoleting.NonFinalMinPeriod != 0 && -- cgit mrf-deployment