runtime: online slice/map pre-sizing #64703
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
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:
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.-> already done: https://cs.opensource.google/go/go/+/master:src/runtime/slice.go;l=218;drc=d6ef98b8fa4851f025779ef4ade084d63290de2acc @cherrymui @mknyszek @aclements @hoeppi-google
The text was updated successfully, but these errors were encountered: