cmd/compile: big map literal creation performance #43020
Labels
FrozenDueToAge
NeedsFix
The path to resolution is known, but the work has not been done.
Performance
Milestone
I noticed that creating big maps (>=9 elements) using map literals are slow if values are not constant
So this code
works twice as slow then this one
See a post
https://trams.github.io/golang-map-literal-performance/
plus here are benchmarks I used
https://github.com/trams/goplayground/blob/main/map_make_test.go
I asked about this in go developers mailing list and they asked to create a ticket
@josharian mentioned this line in the code cmd/compile/internal/gc/sinit.go:757
What version of Go are you using (
go version
)?go1.15.5 linux
Does this issue reproduce with the latest release?
Yes
What operating system and processor architecture are you using (
go env
)?Linux, AMD64
go env
OutputWhat did you do?
Created a map using map literal
What did you expect to see?
I expected go to allocate enough space for all keys so there won't be any additional allocation and performance would be as good as creating a map manually (and specifying appropriate capacity manually using make)
What did you see instead?
There was not enough space allocated so during creation there was a bunch of additional allocs which is shown by benchmarks
The text was updated successfully, but these errors were encountered: