]> Cypherpunks repositories - gostls13.git/commit
runtime: use MADV_FREE_REUSABLE on darwin
authorMichael Anthony Knyszek <mknyszek@google.com>
Wed, 23 Jan 2019 17:33:35 +0000 (17:33 +0000)
committerMichael Knyszek <mknyszek@google.com>
Mon, 4 Mar 2019 18:28:52 +0000 (18:28 +0000)
commitabf8e355a8fe4b77009cb55f6bef11f74e6ade03
tree736d0403899bd587f45e753d9adcbd3fcbb34e5f
parent0c7cdb49d89b34baf1f407135b64fd38876823e2
runtime: use MADV_FREE_REUSABLE on darwin

Currently on darwin we use MADV_FREE, which unfortunately doesn't result
in a change in the process's RSS until pages actually get kicked out,
which the OS is free to do lazily (e.g. until it finds itself under
memory pressure).

To remedy this, we instead use MADV_FREE_REUSABLE which has similar
semantics, except that it also sets a reusable bit on each page so the
process's RSS gets reported more accurately. The one caveat is for every
time we call MADV_FREE_REUSABLE on a region we must call MADV_FREE_REUSE
to keep the kernel's accounting updated.

Also, because this change requires adding new constants that only exist
on darwin, it splits mem_bsd.go into mem_bsd.go and mem_darwin.go.

Fixes #29844.

Change-Id: Idb6421698511138a430807bcbbd1516cd57557c8
Reviewed-on: https://go-review.googlesource.com/c/go/+/159117
Reviewed-by: Brad Fitzpatrick <bradfitz@golang.org>
Run-TryBot: Michael Knyszek <mknyszek@google.com>
TryBot-Result: Gobot Gobot <gobot@golang.org>
src/runtime/defs_darwin.go
src/runtime/defs_darwin_386.go
src/runtime/defs_darwin_amd64.go
src/runtime/defs_darwin_arm.go
src/runtime/defs_darwin_arm64.go
src/runtime/mem_bsd.go
src/runtime/mem_darwin.go [new file with mode: 0644]