You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
This was part of the switch to regabi, we had to build a closure for anything go'd. I believe the CL is https://go-review.googlesource.com/c/go/+/298669
So this is definitely expected. I don't think there's a fundamental reason why this allocation is necessary, but fixing it will certainly be complicated.
In any case, there are more allocations going on when going a function (a runtime.g and a stack, at least). This allocation is minor in comparison. @thanm@cherrymui@dr2chase
Yes, this is expected behavior. Doing things this way made things much simpler for defer and go() handling with the register ABI. As Keith points out, the closure allocation is small potatoes compared with the other things that have to happen to create a new goroutine.
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes. From 1.18 to latest
Don't see the problem on 1.17.13 and older
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Run following benchmark
What did you expect to see?
I expect no variable escape and no memory allocation at benchmark
Before go 1.18, compiled asm was like:
Variables were allocated on caller's stack frame
What did you see instead?
The text was updated successfully, but these errors were encountered: