On Mon, Jan 09, 2012 at 12:33:49AM +0200, Török Edwin wrote:
> On 01/08/2012 09:00 PM, Richard W.M. Jones wrote:
> >Probably the OCaml GC should be setting madvise hints anyway.
>
> It should mmap()/munmap() instead of malloc/realloc/free in that
> case, right?  Which probably wouldn't be a bad idea, as you don't
> get the fragmentation issues as much as you do with malloc.

Simply ensuring the mallocs are aligned to pages (ie using
posix_memalign) should be sufficient to allow madvise to be used.  As
you say it may be better to use mmap for other reasons.

> >While we're at it, the GC may be able to cooperate better with the
> >new(-ish) Transparent Hugepages feature of Linux.
> 
> Does it suffice to allocate the major heap in 2MB increments to take 
> advantage of that?

Yes.

Check this file: /sys/kernel/mm/transparent_hugepage/enabled
If it says:

[always] advise never

then any contiguous anonymous (ie. malloc) virtual memory mapping
which is 2MB or larger and aligned to 2MB is a candidate for being
turned into THPs.  It's thus very easy to use and most processes get
it for free.

Certain kernel operations cause huge pages to be split.  Things like
creating a futex in a page.  So you have to be a bit careful.  This
talk by my colleague explains THP (in the context of KVM, but applies
to any process):

http://www.linux-kvm.org/wiki/images/9/9e/2010-forum-thp.pdf

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