-
Notifications
You must be signed in to change notification settings - Fork 17.9k
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
cmd/compile: go:linkname prevents inlining #20019
Comments
cc'ing @josharian |
At first glance, looks like an import/export issue--the function body is not associated correctly (or perhaps not exported at all) when linkname is present. |
It's possible to quickly estimate the benefits -- make procPin/Unpin public in runtime and directly call from sync.Pool. @valyala care to prototype? |
@josharian If I understand correctly, linkname is resolved at link time (as the name suggests). The runtime package doesn't export those names. |
@dvyukov , sure:
|
@cherrymui but I believe we do have inlining information in the export data for non-exported function, specifically for (multi-level) inlining. |
@josharian you're right, thanks! |
@cherrymui true. And that doesn't seem too much to ask, if you're already using go:linkname. :) Although this also reproduces with package sync (in pool.go), which does already import package runtime. |
I think the issue is just in bimport.go and trivially fixable. @dvyukov do you have an easy standalone test case for this? |
@mdempsky no, I don't. I was looking at sync_runtime_procPin. |
Thanks. I can repro the issue, but realized it's more involved than simply tweaking bimport.go. Currently, we associate function inlining bodies only at the individual Node level. To fix this, we'll need to cross-reference them via LSyms. |
Not sure that's worth it at the moment. |
If this is fixed I believe we can also rewrite |
Gentle ping. |
In general, my preference would be towards more internal packages, rather than more use of As for enabling inlining of |
go version devel +33c3477039 Tue Apr 18 03:56:16 2017 +0000 linux/amd64
sync_runtime_procPin
is marked with//go:linkname sync_runtime_procPin sync.runtime_procPin
. Runtime marks it as inlinable (which is good). However, sync fails to inline it withcannot inline runtime_canSpin: no function body
.There are more functions exposed from runtime to sync, sync/atomic, reflect, time, os.
Can we inline them?
The text was updated successfully, but these errors were encountered: