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

Open
josharian opened this Issue Apr 30, 2017 · 0 comments

Comments

Projects
None yet
1 participant
@josharian
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 label Apr 30, 2017

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment