4 ms·
It seems to me they could have used the following hack to fix such issue: var dontOptimizeMeBro byte // go:noinline func makeStackBig() { var buf [1
by kjksf 8y ago
It seems to me they could have used the following hack to fix such issue:
var dontOptimizeMeBro byte
// go:noinline
func makeStackBig() {
var buf [16386]byte
dontOptimizeMeBro = buf[0] + buf[len(buf)-1]
}
Call this at the start of the goroutine.
What it does, I hope, is extend stack to 16kb, once (as opposed to going from 2kb to 4kb then to 8kb then to 16kb and paying for coyping the memory multiple times).
The stack stays big for the remaining lifetime of the goroutine.
- richieartoul 8y agoYep that works too although I didn't benchmark the difference in performance. The nice thing about the worker pool though is that it auto-tunes the stack size based on the workload.