-
Notifications
You must be signed in to change notification settings - Fork 17.5k
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: better append of unmodified slices #37694
Comments
@randall77, I think you've got the title backwards. It looks like the sliced array is outperforming the slice-literal version for some reason. |
Sorry, yes. |
Slow routine allocates because len(base)+len(fixed) of slices isn't determined at compile time, whereas with arrays the expression is constant. |
Or to be more precise, during the escape analysis phase, |
So both are optimized to the extent of what they can be or is there room for improvement in the slice case ? |
It’s definitely possible for them to be improved. The question—which I can’t answer offhand—is whether it is possible to make a small, local improvement that would cover this case, or whether it would require an overhaul. (There are good independent reasons for an overhaul, but what is needed—eliminating one of the compiler’s intermediate representations—is a huge undertaking.) |
Is this a duplicate of #20533? |
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?
What did you expect to see?
I would have expected
BenchmarkCapNoMagicNumber
andBenchmarkCapNoMagicNumberFixedSlices
to have the same throughput.What did you see instead?
The text was updated successfully, but these errors were encountered: