Bisecting Go performance degradation

Charles Darwin — just a nice first picture for a post and a hint for an impatient reader.
func BenchmarkWrite(b *testing.B) {
f, err := os.Create("/dev/null")
if err != nil {
defer f.Close()
buf := make([]byte, 512) b.ResetTimer()
for i := 0; i < b.N; i++ {
go get
go1.11 download
go get
go1.12 download
$ go1.11 test -bench=BenchmarkWrite -benchmem -memprofile mem.old -cpuprofile cpu.old | tee old.benchgoos: darwin
goarch: amd64
BenchmarkWrite-8 1000000 1167 ns/op 0 B/op 0 allocs/opPASS
ok 1.201s
$ go1.12 test -bench=BenchmarkWrite -benchmem -memprofile -cpuprofile | tee new.benchgoos: darwin
goarch: amd64
BenchmarkWrite-8 1000000 2184 ns/op 0 B/op 0 allocs/opPASS
ok 2.226s
$ benchcmp old.bench new.benchbenchmark            old ns/op     new ns/op     delta
BenchmarkWrite-8 1167 2184 +87.15%
benchmark old allocs new allocs delta
BenchmarkWrite-8 0 0 +0.00%
benchmark old bytes new bytes delta
BenchmarkWrite-8 0 0 +0.00%
$ go tool pprof cpu.old
> web
$ go tool pprof
> web
$ git rev-list --no-walk go1.11..go1.12 | wc -l
git clone ~/
mkdir regression_search
benchmany -d regression_search -order metric -benchflags ' -test.bench=BenchmarkWrite' -buildcmd='/Users/ayuemelin/ test -c' -C /Users/ayuemelin/ go1.11..go1.12
commit 5e9ad4a, iteration 1/5: building...
commit 5e9ad4a, iteration 1/5: running...
commit 5e9ad4a, iteration 2/5: running...
commit 5e9ad4a, iteration 3/5: running...
commit 5e9ad4a, iteration 4/5: running...
commit 5e9ad4a, iteration 5/5: running...
commit ef21689, iteration 1/5: building...
45/360 runs, 63 unstarted+0 partial+9 done+0 failed commits, ETA 1h28m36s
  • You need to run your benchmarks on a main target system
  • You can run benchmark in your project automatically against different Go revisions using benchmany tool
  • You can bisect simply enough which commit caused regression in your Go code using benchmany -order metric
  • Sometimes a quick Twitter search can resolve the root cause of problem :)




Love podcasts or audiobooks? Learn on the go with our new app.

Recommended from Medium

What are your programming weaknesses?

Orchestrating your first pipeline on Apache Airflow with LocalExecutor

Food for Agile Thought #189

Deploying Flutter with Github Actions

A Debugging Primer with CVE-2019–0708

What is Reliability

Unlock Modern Portal

Head in the Clouds: Microsoft Azure

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store
Alexander Emelin

Alexander Emelin


More from Medium

A good summary of Go lang basic syntax

Delve With VSCode To Debug Go App

TicTacGo — An Intro to Golang