From: Michael Anthony Knyszek Date: Fri, 23 Apr 2021 22:20:55 +0000 (+0000) Subject: runtime: fix scavenge min fraction constant floor division X-Git-Tag: go1.17beta1~450 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=14ade57ab8f2a6b9608fc3cab57957f39caead40;p=gostls13.git runtime: fix scavenge min fraction constant floor division Currently there's a minor bug where the constant for the min fraction of time spent scavenging is rounded down to zero. I don't think this affects anything in practice because this case is exceedingly rare and extreme, but currently it doesn't properly prevent the pacing parameters from getting out of hand in these extreme cases. Fixes #44036. Change-Id: I7de644ab0ecac33765c337a736482a0966882780 Reviewed-on: https://go-review.googlesource.com/c/go/+/313249 Reviewed-by: Michael Pratt Trust: Michael Knyszek Run-TryBot: Michael Knyszek TryBot-Result: Go Bot --- diff --git a/src/runtime/mgcscavenge.go b/src/runtime/mgcscavenge.go index 7e32348670..7578129f9d 100644 --- a/src/runtime/mgcscavenge.go +++ b/src/runtime/mgcscavenge.go @@ -372,7 +372,7 @@ func bgscavenge() { // Due to OS-related anomalies we may "sleep" for an inordinate amount // of time. Let's avoid letting the ratio get out of hand by bounding // the sleep time we use in our EWMA. - const minFraction = 1 / 1000 + const minFraction = 1.0 / 1000.0 if fraction < minFraction { fraction = minFraction }