5 ms·
It actually did get significantly better in Go 1.8, in early 2017. See https://golang.org/doc/go1.8 https://golang.org/doc/go1.8 ("The overhead of deferred fun
by yalue 8y ago
It actually did get significantly better in Go 1.8, in early 2017. See https://golang.org/doc/go1.8 https://golang.org/doc/go1.8 ("The overhead of deferred function calls has been reduced by about half.").
However, I think this change was mostly just an optimization for common cases with few arguments or no closures (e.g. "defer f.Close()").
- cyphar 8y agoI just re-did the benchmarks with Go 1.11.5, it is much better but it's still 4 orders of magnitude more than "a few nanoseconds".