Navigation Menu

Skip to content
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: for loop prevents inlining #22636

Closed
TocarIP opened this issue Nov 8, 2017 · 2 comments
Closed

cmd/compile: for loop prevents inlining #22636

TocarIP opened this issue Nov 8, 2017 · 2 comments

Comments

@TocarIP
Copy link
Contributor

TocarIP commented Nov 8, 2017

What version of Go are you using (go version)?

go version devel +ef0e2af Mon Nov 6 15:55:31 2017 +0000 linux/amd64

Go currently performs inlining of small functions, but if it encounters any explicit loop construct, such as for loop, function is never inlined. This causes code to use goto instead (e. g. tryWriteCopy in compress/flate/dict_decoder_test.go in standard library) to simulate loops. Inlining functions with loops can significantly improve performance. For example replacing for with goto in PutUvarint (in encoding/binary) results in 40% speed-up.

PutUvarint64-6     119ns ± 0%       67ns ± 1%  -43.91%  (p=0.000 n=8+10)

I'd prefer to get this speed-up without uglyfing code with goto.

@huguesb
Copy link
Contributor

huguesb commented Nov 8, 2017

Dup of #14768

@TocarIP
Copy link
Contributor Author

TocarIP commented Nov 8, 2017

Sorry, I've missed it somehow.

@TocarIP TocarIP closed this as completed Nov 8, 2017
@golang golang locked and limited conversation to collaborators Nov 8, 2018
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants