]> Cypherpunks repositories - gostls13.git/commit
runtime: reserve fewer memory for aligned reservation on sbrk systems
authorCherry Mui <cherryyz@google.com>
Mon, 21 Oct 2024 21:45:01 +0000 (17:45 -0400)
committerCherry Mui <cherryyz@google.com>
Fri, 25 Oct 2024 17:13:47 +0000 (17:13 +0000)
commit22664f33b7389f1b3df409a831c83213cfbbe6d3
tree2239ff9b337717499834139fd5abcf843074b364
parent0addb2a4ea77b3e8b08a02966e381a812082f58b
runtime: reserve fewer memory for aligned reservation on sbrk systems

Sometimes the runtime needs to reserve some memory with a large
alignment, which the OS usually won't directly satisfy. So, it
asks size+align bytes instead, and frees the unaligned portions.
On sbrk systems, this doesn't work that well, as freeing the tail
portion doesn't really free the memory to the OS. Instead, we
could simply round the current break up, then reserve the given
size, without wasting the tail portion.

Also, don't create heap arena hints on sbrk systems. We can only
grow the break sequentially, and reserving specific addresses
would not succeed anyway.

For #69018.

Change-Id: Iadc2c54d62b00ad7befa5bbf71146523483a8c47
Reviewed-on: https://go-review.googlesource.com/c/go/+/621715
Reviewed-by: Michael Knyszek <mknyszek@google.com>
LUCI-TryBot-Result: Go LUCI <golang-scoped@luci-project-accounts.iam.gserviceaccount.com>
Reviewed-by: Michael Pratt <mpratt@google.com>
src/runtime/malloc.go
src/runtime/mem_nonsbrk.go [new file with mode: 0644]
src/runtime/mem_sbrk.go