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

runtime: online slice/map pre-sizing #64703

Open
prattmic opened this issue Dec 13, 2023 · 2 comments
Open

runtime: online slice/map pre-sizing #64703

prattmic opened this issue Dec 13, 2023 · 2 comments
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Milestone

Comments

@prattmic
Copy link
Member

prattmic commented Dec 13, 2023

The goal here is to reduce excessive time spent growing slices and maps.

The idea would be to track slice/map declaration/allocation sites (by PC, perhaps including N frames of caller context for additional precision) and the typical (approximate median?) maximum size of containers from that allocation site. Future allocations would use the median to allocate the expected size up front, thus avoid grow work.

Some thoughts from initial discussions:

cc @cherrymui @mknyszek @aclements @hoeppi-google

@prattmic prattmic added this to the Backlog milestone Dec 13, 2023
@gopherbot gopherbot added the compiler/runtime Issues related to the Go compiler and/or runtime. label Dec 13, 2023
@prattmic prattmic added the NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. label Dec 13, 2023
@randall77
Copy link
Contributor

Partially related to this: when growing, should we always align up to fill the entire size class. Leaving extra space in the size class is pure waste.

I believe we already do that.

@prattmic
Copy link
Member Author

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
compiler/runtime Issues related to the Go compiler and/or runtime. NeedsInvestigation Someone must examine and confirm this is a valid issue and not a duplicate of an existing one. Performance
Projects
Development

No branches or pull requests

3 participants