bench: remove manual GC from garbage benchmark
Initially the garbage benchmark was flaky because
some runs trigger 3 GCs while others trigger 4 GCs.
This caused 33% flakes.
Then I've added the manual GC triggering that emulates
GOGC=100 but more stable. This fixed the flakiness.
Then we've changed runtime.GC so that it executes 2 GCs.
This increased GC time by 50%, and numbers between releases
become uncomparable.
I don't have a better idea than to remove the manual GC triggerring.
LGTM=adg
R=adg
CC=golang-codereviews, rsc
https://golang.org/cl/88040051
diff --git a/driver/driver_go10.go b/driver/driver_go10.go
index 8d2a3f4..2874b98 100644
--- a/driver/driver_go10.go
+++ b/driver/driver_go10.go
@@ -13,7 +13,3 @@
// New mem stats added in Go1.2
func collectGo12MemStats(res *Result, mstats0, mstats1 *runtime.MemStats) {
}
-
-func SetGCPercent(x int) bool {
- return false
-}
diff --git a/driver/driver_go12.go b/driver/driver_go12.go
index 87b3dad..8dfed01 100644
--- a/driver/driver_go12.go
+++ b/driver/driver_go12.go
@@ -8,7 +8,6 @@
import (
"runtime"
- "runtime/debug"
)
// New mem stats added in Go1.2
@@ -16,9 +15,3 @@
res.Metrics["sys-gc"] = mstats1.GCSys
res.Metrics["sys-other"] = mstats1.OtherSys + mstats1.MSpanSys + mstats1.MCacheSys + mstats1.BuckHashSys
}
-
-func SetGCPercent(x int) bool {
- debug.SetGCPercent(x)
- runtime.GC()
- return true
-}
diff --git a/garbage/garbage.go b/garbage/garbage.go
index 31bccb3..816adb5 100644
--- a/garbage/garbage.go
+++ b/garbage/garbage.go
@@ -26,8 +26,7 @@
type ParsedPackage map[string]*ast.Package
var (
- parsed []ParsedPackage
- manualGC bool
+ parsed []ParsedPackage
)
func benchmark() driver.Result {
@@ -42,11 +41,6 @@
}
}
fmt.Printf("consumption=%vKB npkg=%d\n", mem>>10, npkg)
- // Disable GC, we will trigger GC manually at predictable points.
- // This helps to avoid a situation when one run triggers 3 GCs,
- // and then a subsequent run triggers 4 GCs, which causes
- // significant fluctuations in results.
- manualGC = driver.SetGCPercent(10000)
}
return driver.Benchmark(benchmarkN)
}
@@ -72,10 +66,6 @@
// the other part represents "old" generation.
parsed[pos%(len(parsed)/2)] = p
pos++
- // This condition is roughy equal to GCGC=100, but is more stable.
- if manualGC && (pos%len(parsed)) == 0 {
- runtime.GC()
- }
mu.Unlock()
<-gate
}