aboutsummaryrefslogtreecommitdiff
path: root/src/runtime/defs_darwin.go
diff options
context:
space:
mode:
authorMichael Anthony Knyszek <mknyszek@google.com>2019-01-23 17:33:35 +0000
committerMichael Knyszek <mknyszek@google.com>2019-03-04 18:28:52 +0000
commitabf8e355a8fe4b77009cb55f6bef11f74e6ade03 (patch)
tree736d0403899bd587f45e753d9adcbd3fcbb34e5f /src/runtime/defs_darwin.go
parent0c7cdb49d89b34baf1f407135b64fd38876823e2 (diff)
downloadgo-abf8e355a8fe4b77009cb55f6bef11f74e6ade03.tar.gz
go-abf8e355a8fe4b77009cb55f6bef11f74e6ade03.zip
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>
Diffstat (limited to 'src/runtime/defs_darwin.go')
-rw-r--r--src/runtime/defs_darwin.go6
1 files changed, 4 insertions, 2 deletions
diff --git a/src/runtime/defs_darwin.go b/src/runtime/defs_darwin.go
index d5dc7944ee..61ae7a4186 100644
--- a/src/runtime/defs_darwin.go
+++ b/src/runtime/defs_darwin.go
@@ -41,8 +41,10 @@ const (
MAP_PRIVATE = C.MAP_PRIVATE
MAP_FIXED = C.MAP_FIXED
- MADV_DONTNEED = C.MADV_DONTNEED
- MADV_FREE = C.MADV_FREE
+ MADV_DONTNEED = C.MADV_DONTNEED
+ MADV_FREE = C.MADV_FREE
+ MADV_FREE_REUSABLE = C.MADV_FREE_REUSABLE
+ MADV_FREE_REUSE = C.MADV_FREE_REUSE
SA_SIGINFO = C.SA_SIGINFO
SA_RESTART = C.SA_RESTART