I noticed that making of Go maps was missing from the original proposal in #51317. The proposal says:
Another open issue is whether arenas can be used for allocating the elements of a map. This is
possible, but it is not clear what a good API would be. Also, there might be unusual cases if the arena used for the main map object is different from the arena used to allocate new elements of the map.
Perhaps I'm missing something, but couldn't we construct a Go map with an arena registered with it such that all allocations needed by the map are performed out of the arena? Thus, we're not directly allocating the elements of a map, but rather the entire map and (indirectly any map elements henceforth).
Something like:
// MakeMap creates a new map[K]V with the provided capacity.
// The map[K]V must not be used after the arena is freed.
// Accessing the underlying storage of the map after free may result in a fault,
// but this fault is also not guaranteed.
func MakeMap[K comparable, V any](a *Arena, cap int) map[K]V { ... }
\cc @danscales
I noticed that making of Go maps was missing from the original proposal in #51317. The proposal says:
Perhaps I'm missing something, but couldn't we construct a Go map with an arena registered with it such that all allocations needed by the map are performed out of the arena? Thus, we're not directly allocating the elements of a map, but rather the entire map and (indirectly any map elements henceforth).
Something like:
\cc @danscales