caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: ygrek <ygrekheretix@gmail.com>
To: caml-list@inria.fr
Subject: Re: [Caml-list] Memory fragmentation
Date: Sat, 21 Apr 2012 00:32:19 +0300	[thread overview]
Message-ID: <20120421003219.ce3d8b2c.ygrekheretix@gmail.com> (raw)
In-Reply-To: <CAHgca+_OD0twkZ6WPc2bkQtEAS6Qnj1ogTDLE-S4esw6GKAV9A@mail.gmail.com>

On Fri, 20 Apr 2012 19:12:12 +0400
SerP <serp256@gmail.com> wrote:

> Hi!
> We have developped a daemon on ocaml using the lwt lib(libev). It processes
> about 800 requests per second, but it increases to 2 Gb in memory for a
> hour of work. We have studied the problem for a long time, using mtrace,
> mallinfo and other tools, and we tried to change GC params. We found out
> that setting up GC.minor_heap_size=10Mb а major_heap_increment=2Мb will
> make the daemon grow slower. mallinfо shows that the memory (1,5G) is
> allocated using mmap (blkhd field in mallinfo struct) and arena size -
> about 20M In this case, first calls of GC.compact compress the daemon to
> 200 Mb (live -110Mb) , and mallinfo show decreasing of total size of memory
> allocated by mmap. The daemon keeps growing, but it allocates the memory to
> arena (using brk), and calls of GC.compact leads to decrease of heap_bytes
> to 200M, but arena size (1.5 Gb) does not decrease, just doing less
> uordblks and more fordblks (fileds I.e., after first calls of GC.compact,
> the daemon starts using brk much more than mmap, and cant memory given back
> to the system.

Alternative malloc implementation may well be worth a try. I've seen the cases
when glibc was constantly growing RSS while tcmalloc was on stable level (and 10x less), 
guessing due to fragmentation.
Maybe related, see PR#5389 for ocaml compaction related issues.
Also have a look at http://ygrek.org.ua/p/code/mlvalues.py for the way to peep
into ocaml heap at runtime.

-- 
 ygrek
 http://ygrek.org.ua

  parent reply	other threads:[~2012-04-20 21:35 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
     [not found] <CAHgca+9-K71NynNVzS0Stnb2v5Tc6n5ecCnJHZorhuB8y8EdTw@mail.gmail.com>
2012-04-20 15:12 ` SerP
2012-04-20 15:27   ` [Caml-list] " SerP
2012-04-20 16:41   ` [Caml-list] " Török Edwin
2012-04-20 18:32     ` SerP
2012-04-20 21:32   ` ygrek [this message]
2012-04-21  7:26   ` rixed
2012-04-24 19:24     ` SerP

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=20120421003219.ce3d8b2c.ygrekheretix@gmail.com \
    --to=ygrekheretix@gmail.com \
    --cc=caml-list@inria.fr \
    /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;
as well as URLs for NNTP newsgroup(s).