On Sun, Jan 08, 2012 at 06:45:05PM +0000, Richard W.M. Jones wrote:
> And that brings us to (c): does it even make sense to give back memory
> to the OS?

I forgot to mention one way in which this is more efficient: If you
munmap a piece of memory and later decide you need more memory so you
call mmap, then the kernel has to give you zeroed memory.  You
probably didn't want zeroed memory, but you pay the penalty anyway.

(The converse of this is that if your unused memory is swapped out,
then it has to be written to disk and read back, which is even less
efficient.)

There is an madvise flag "MADV_DONTNEED" which is better than munmap +
mmap, although not as optimal as it could be.  See links below.

http://gcc.gnu.org/ml/gcc-patches/2011-10/msg00733.html
http://www.reddit.com/r/programming/comments/dp5up/implementations_for_many_highlevel_programming/c120n77

Probably the OCaml GC should be setting madvise hints anyway.

While we're at it, the GC may be able to cooperate better with the
new(-ish) Transparent Hugepages feature of Linux.

I wonder if anyone has looked into these things to see if there are
any quick wins to be had?

Rich.

-- 
Richard Jones
Red Hat

-- 
Caml-list mailing list.  Subscription management and archives:
https://sympa-roc.inria.fr/wws/info/caml-list
Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
Bug reports: http://caml.inria.fr/bin/caml-bugs

Reply via email to