Re: [golang-dev] code review 7310094: runtime: Do not reserve huge amount of swap on 32 bit a... (issue 7310094)

5 views
Skip to first unread message

minux

unread,
Feb 14, 2013, 11:52:26 AM2/14/13
to sn...@epipe.com, gofront...@googlegroups.com, re...@codereview-hr.appspotmail.com, golang-dev
please send gccgo CLs to the gofrontend-dev ML.

i think we'd better patch this to master Go runtime as it's not specific to gccgo runtime.

add the macro definition to pkg/runtime/defs_linux_{386,amd64,arm}.h and pkg/runtime/defs_linux.go
and then use it in pkg/runtime/mem_linux.c.

PS: if you're sure the value of the macro is uniform across all architectures supported
by Linux, you could add the definition to os_linux.h instead of defs_linux*.

Janne Snabb

unread,
Feb 14, 2013, 12:15:19 PM2/14/13
to minux, gofront...@googlegroups.com, re...@codereview-hr.appspotmail.com
On 2013-02-14 18:52, minux wrote:
> please send gccgo CLs to the gofrontend-dev ML.

Oops, sorry. I did not know about this list. It is not mentioned at the
relevant page: http://golang.org/doc/gccgo_contribute.html

> i think we'd better patch this to master Go runtime as it's not specific
> to gccgo runtime.
>
> add the macro definition to pkg/runtime/defs_linux_{386,amd64,arm}.h and
> pkg/runtime/defs_linux.go
> and then use it in pkg/runtime/mem_linux.c.
>
> PS: if you're sure the value of the macro is uniform across all
> architectures supported
> by Linux, you could add the definition to os_linux.h instead of defs_linux*.

I tried this out on 32 bit Linux and it did not solve any problem there
even if running with "vm.overcommit_memory=2" (which should disable
memory overcommit).

The mmap() without MAP_NORESERVE does not seem to reserve the swap space
on Linux (which seems to contradict with the mmap(2) manual page). The
flag makes no difference there. I am able to start a big amount of Go
program processes even when the overcommit is disabled.

The virtual memory consumption number in ps output (VSZ) and the "pmap
PID" output remains the same no matter if this flag is specified or not.

Therefore I thought I should not suggest patching mem_linux.c.

--
Janne Snabb / EPIPE Communications
sn...@epipe.com - http://epipe.com/

ia...@golang.org

unread,
Feb 15, 2013, 1:54:54 PM2/15/13
to sn...@epipe.com, golan...@googlegroups.com, minu...@gmail.com, da...@cheney.net, gofront...@googlegroups.com, re...@codereview-hr.appspotmail.com
*** Submitted as
https://code.google.com/p/gofrontend/source/detail?r=29b742a2ed37 ***

runtime: Do not reserve huge amount of swap on 32 bit architectures.

The mmap() call which reserves the arena should have MAP_NORESERVE
flag as in typical cases this memory will never be (fully) needed.
This matters in environments which do not do Linux style memory
overcommit, such as OpenIndiana/OpenSolaris/Solaris.

The MAP_NORESERVE flag does not exist on all operating systems
(for example FreeBSD). Therefore we define it to zero value in
case it does not exist.

Fixes issue 21.

R=golang-dev, minux.ma, iant, dave
CC=gofrontend-dev, golang-dev
https://codereview.appspot.com/7310094

Committer: Ian Lance Taylor <ia...@golang.org>


https://codereview.appspot.com/7310094/
Reply all
Reply to author
Forward
0 new messages