Join GitHub today
GitHub is home to over 20 million developers working together to host and review code, manage projects, and build software together.
cmd/compile: inline function calls that return a closure #10292
Comments
bradfitz
added
the
Performance
label
Mar 31, 2015
|
In case the link above breaks, the code in question is:
|
rsc
added this to the Unplanned milestone
Apr 10, 2015
rsc
changed the title from
cmd/gc: Inline function calls that return a closure
to
cmd/gc: inline function calls that return a closure
Apr 10, 2015
rsc
changed the title from
cmd/gc: inline function calls that return a closure
to
cmd/compile: inline function calls that return a closure
Jun 8, 2015
ALTree
referenced this issue
Aug 17, 2016
Closed
cmd/compile: inline harder to optimize closure allocation #16759
|
I have a WIP for this, which seems to work fine when building a single-package executable but fails as soon as multiple packages are involved since the exporter/importer do not handle @griesemer I'm trying to add support for the How does one test changes to the export format? Is the workflow affected by the recent caching work by @rsc ? edit: nevermind, I stupidly forgot to update the version check in |
|
Hughes, how are you testing/recompiling the Compiler after you change? Perhaps I can suggest a solution.
…
|
|
@davecheney I figured out what was going wrong. Thanks for the offer to help though :) At this point, my WIP can inline functions with closures that do not capture variables and works fine across packages. I'll upload a CL as soon as I figure out how to properly handle captures (or when I get stuck and need to ask for help). Interestingly, |
potocnyj commentedMar 31, 2015
https://go-review.googlesource.com/#/c/8200/ added a benchmark to the strings package that shows strings.Trim and its variants allocate memory. The allocation is caused by the call to makeCutsetFunc here. Inlining this call removes the allocation and provides a nice performance boost to Trim. You can see the effect on the benchmark using Go Tip (commit 6262192) below:
makeCutsetFunc is a pretty simple function (all it does is return a closure), and it was pointed out in review that it might be nice to inline functions like it in the compiler rather than changing strings.Trim explicitly.