runtime: reserve address space for large slice backing stores to make slice growth cheaper #57337
Labels
compiler/runtime
Issues related to the Go compiler and/or runtime.
FeatureRequest
Issues asking for a new feature that does not need a proposal.
NeedsInvestigation
Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.
Milestone
When append() sees the underlying array is used to capacity, it allocates a bigger array, copies values, zeroes the rest, and returns.
This proposal will make this grow() logic cheaper:
If the OS offered an extend() then it would be possible to avoid the copy. However this is unlikely because the following virtual address space is often claimed already.
Q: In supported 64-bit OSes, what if all unbounded requests asked the OS for 1TB of reserved memory?
A: Then most all grow() calls could just claim and zero the next chunk of reserved memory. That's because extra reserved memory is just an address until it page-faults into existence.
In practical terms, I see 2 ways to go:
There's likely a refinement sweet-spot around the variables of:
The text was updated successfully, but these errors were encountered: