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: wasted bucket allocated on stack for non-escaping map when hint is not small #20184

Closed
josharian opened this issue Apr 30, 2017 · 1 comment
Labels
FrozenDueToAge Performance Suggested Issues that may be good for new contributors looking for work to do.
Milestone

Comments

@josharian
Copy link
Contributor

josharian commented Apr 30, 2017

When there's a non-escaping map, we allocate a bucket for it on the stack. See walk.go, func walkexpr, case OMAKEMAP. But if there's a size hint big enough that we want to preallocate some buckets non-lazily, we ignore the bucket parameter passed to makemap. See hashmap.go, func makemap, handling of buckets param. We should not allocate a bucket on the stack if we're just going to ignore it in makemap.

This requires cmd/compile knowing whether the runtime will decide it needs to preallocate some buckets. There's already a lot of shared (duplicated) knowledge between the compiler and runtime, so this isn't the end of the world.

Low priority, since this case is probably rare. But this might make a good starter project for someone interested in the compiler.

@josharian josharian added this to the Unplanned milestone Apr 30, 2017
@josharian josharian added the Suggested Issues that may be good for new contributors looking for work to do. label Apr 30, 2017
@gopherbot
Copy link

Change https://golang.org/cl/227458 mentions this issue: cmd/compile: do not allocate bucket on stack for non-escaping map

@golang golang locked and limited conversation to collaborators Apr 9, 2021
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
FrozenDueToAge Performance Suggested Issues that may be good for new contributors looking for work to do.
Projects
None yet
Development

No branches or pull requests

2 participants