Full Category Index
Posts in “Go”
Defer overhead in go
Prelude
This post based on
real events
in docker repository.
When I revealed that my 20-percent-cooler refactoring made Pop function x4-x5
times slower, I did some research and concluded, that problem was in using
defer statement for unlocking everywhere.
In this post I’ll write simple program and benchmarks from which we will see,
that sometimes defer statement can slowdown your program a lot.
Let’s create simple queue with methods Put and Get. Next snippets shows such
queue and benchmarks for it. Also I wrote duplicate methods with defer and
without it.