-
Notifications
You must be signed in to change notification settings - Fork 18.5k
Open
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Milestone
Description
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:
- Expressing 1TB of capacity to the user would require either zeroing on exposure.
- Expressing a much smaller capacity to the user would require the allocator to have a separate capacity concept that it would consult to determine if a new allocation is necessary (typically not).
There's likely a refinement sweet-spot around the variables of:
- at what growth size should we allocate a giant allocation?
- how big is giant allocation (1TB in the example above)?
- should we have a smaller "giant allocation" for initial slices, like initially 1MB then 1TB?
- Does this upset the Linux OOM killer?
Metadata
Metadata
Assignees
Labels
FeatureRequestIssues asking for a new feature that does not need a proposal.Issues asking for a new feature that does not need a proposal.NeedsInvestigationSomeone must examine and confirm this is a valid issue and not a duplicate of an existing one.Someone must examine and confirm this is a valid issue and not a duplicate of an existing one.compiler/runtimeIssues related to the Go compiler and/or runtime.Issues related to the Go compiler and/or runtime.
Type
Projects
Status
No status