-
Notifications
You must be signed in to change notification settings - Fork 18k
cmd/compile: support inlining of functions containing function literals #28727
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
We do allocate function literals on the stack, if possible. |
The crux of this issue is that functions that contain closures aren't currently inlineable. If FuncA was inlined into BenchmarkTestA, then I expect escape analysis would detect that it can be stack allocated. |
Change https://golang.org/cl/267880 mentions this issue: |
Change https://golang.org/cl/283112 mentions this issue: |
What version of Go are you using (
go version
)?Does this issue reproduce with the latest release?
Yes.
What operating system and processor architecture are you using (
go env
)?go env
OutputWhat did you do?
Looking at the following benchmarks, returning a func literal always gets allocated on the heap while a similar approach using a struct can be allocated on the stack. I propose that func literals are also assessed whether they can be put on the stack or on the heap.
giving
When this func literal would be allocated on the stack, we would see a ~10x performance increase.
The text was updated successfully, but these errors were encountered: