]> Cypherpunks repositories - gostls13.git/commit
cmd/link: reduce Wasm initial memory size
authorCherry Mui <cherryyz@google.com>
Mon, 21 Oct 2024 17:09:58 +0000 (13:09 -0400)
committerCherry Mui <cherryyz@google.com>
Mon, 21 Oct 2024 21:53:15 +0000 (21:53 +0000)
commit24bc4731739d55826a8adfcdb2aa1217f9db3bc8
tree3563d30f8bb0cffef0fc1b38ff3988188005d13f
parent4510586f930b49a142f991c51d960a3afc18e667
cmd/link: reduce Wasm initial memory size

Currently, for Wasm, the linker sets the initial memory size to
the size of global data plus 16 MB. The intention is that it
covers the global data and runtime initialization without growing
the linear memory. However, the code accounts only the data
"section", not the bss "section", therefore the extra 16 MB is
actually used to cover bss variables. Also, as seen on the
previous CL, the runtime actually didn't use the extra space,
which means the program can start without that space.

This CL corrects the global data size calculation, and reduces the
extra to 1 MB. Currently the runtime's allocation pattern at
startup is that it allocates a few pages for the page allocator's
metadata, the an 8 MB reservation for the first 4 MB size, 4 MB
aligned heap arena (it may be possible to reduce that, but we'll
leave that for later). Here we use 1 MB extra space to cover the
small allocations, but let the runtime allocate the heap arena, so
the linker code and the runtime's allocator are not tightly
coupled.

For #69018.

Change-Id: I39fe1172382ecc03f4b537e43ec710af8075eab3
Reviewed-on: https://go-review.googlesource.com/c/go/+/621636
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
src/cmd/link/internal/wasm/asm.go