Join GitHub today
GitHub is home to over 50 million developers working together to host and review code, manage projects, and build software together.Sign up
GitHub is where the world builds software
Millions of developers and companies build, ship, and maintain their software on GitHub — the largest and most advanced development platform in the world.
runtime: allow users to opt into 4MB arenas #42612
Some embedded Linux platforms disable overcommit to reduce dynamic behavior in the system. Go already uses 4MB arenas on 32-bit platforms, but on 64-bit platforms the initial 64MB arena adds a steep cost to any Go binary.
Allow users to opt into 4MB arenas at build time by passing
I don't think a build tag (or any optional behavior) is the right way to resolve running up against strict overcommit. It's another configuration to maintain.
I think we should consider doing a 64 MiB reservation (
Such a change does mean we can retain the performance benefits of having a shallower arena index on 64-bit platforms (1-2%), but where we lose is that we potentially have to do more syscalls. I personally don't think that's a big deal because heap growths are relatively rare whereas we access the arena index extremely often. Notably, we won't have to do more syscalls than on 4 MiB arena platforms since we also already round up
It's a fairly small and easy change to make, though unfortunately I think at this point it will have to wait for Go 1.17, unless I'm wrong.
I agree that I don't want to ship a configuration flag for this. But I like @mknyszek's idea of using mheap.curArena to map the reservation more incrementally. This would also solve #28081 (see in particular #28081 (comment)). I think we have to be careful not to map it in too small of chunks just to reduce
I think this is too late for 1.16, unfortunately, but since it should be a pretty simple change we could make it now and queue it up for 1.17. @mknyszek , care to do the honors?