From: Xavier Leroy <Xavier.Leroy@inria.fr>
To: Vladimir Shabanov <vshabanoff@gmail.com>
Cc: caml-list@inria.fr
Subject: Re: [Caml-list] OCaml runtime using too much memory in 64-bit Linux
Date: Wed, 14 Nov 2007 13:55:40 +0100 [thread overview]
Message-ID: <473AF04C.7030107@inria.fr> (raw)
In-Reply-To: <8ef825670711140403m464c01detff5537abb2211946@mail.gmail.com>
Hello,
Concerning this issue with large page tables on 64-bit architectures,
I opened a problem report on the bug-tracking system to help gather
more information. I'd like to ask all members of this list that
reported the problem to kindly visit
http://caml.inria.fr/mantis/view.php?id=4448
and add the required information as a note. That will help
pinpointing the problem.
Some more explanation on what's going on. The Caml run-time system
needs to keep track of which memory areas belong to the major heap,
and uses a page table for this purpose, with a dense representation
(an array of bytes). If the major heap areas are closely spaced, this
table is very small compared with the size of the heap itself.
However, if these areas are widely spaced in the addressing space, the
table can get big.
For 32-bit platforms, this isn't much of a problem since the maximum
size of the page table is 1 megabytes. For 64-bit platforms, the sky
is the limit, however. So far, the only 64-bit platform where this
has been a problem in the past is Linux with glibc, where blocks
allocated by malloc() can come either from sbrk() or mmap(), two areas
that are spaced several *exa*bytes apart. We worked around the
problem by allocating all major heap areas directly with mmap(),
obtaining closely spaced addresses.
Apparently, this trick is no longer working on some systems, but I
need to understand better which ones exactly. (I suspect some Linux
distros that applied address randomization patches to the stock Linux
kernel.) So, please provide feedback in the BTS.
If the problem is confirmed, there are several ways to go about it.
One is to implement the page table with a sparse data structure,
e.g. a hash table. However, the major GC and some primitives like
polymorphic equality perform *lots* of page table lookups, so a
performance hit is to be expected. The other is to revise OCaml's
data representations so that the GC and polymorphic primitives no
longer need to know which pointers fall in the major heap. This seems
possible in principle, but will take quite a bit of work and break a
lot of badly written C/OCaml interface code. You've been warned :-)
- Xavier Leroy
next prev parent reply other threads:[~2007-11-14 12:55 UTC|newest]
Thread overview: 17+ messages / expand[flat|nested] mbox.gz Atom feed top
2007-11-07 17:28 Adam Chlipala
2007-11-07 18:20 ` [Caml-list] " Gerd Stolpmann
2007-11-07 19:12 ` Adam Chlipala
2007-11-08 12:56 ` Samuel Mimram
2007-11-14 4:20 ` Romain Beauxis
2007-11-14 12:03 ` Vladimir Shabanov
2007-11-14 12:55 ` Xavier Leroy [this message]
2007-11-14 13:45 ` Brian Hurt
2007-11-14 14:16 ` Romain Beauxis
2007-11-14 15:56 ` Markus Mottl
2007-11-14 16:22 ` Stefan Monnier
2007-11-14 16:36 ` [Caml-list] " Brian Hurt
2007-11-14 17:08 ` Lionel Elie Mamane
2007-11-14 17:26 ` Stefan Monnier
2007-11-14 16:45 ` Lionel Elie Mamane
2007-11-14 17:08 ` Lionel Elie Mamane
2007-11-08 20:51 ` [Caml-list] " Romain Beauxis
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=473AF04C.7030107@inria.fr \
--to=xavier.leroy@inria.fr \
--cc=caml-list@inria.fr \
--cc=vshabanoff@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox