caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Eray Ozkural <examachine@gmail.com>
To: Michael Ekstrand <michael@elehack.net>
Cc: caml-list@yquem.inria.fr
Subject: Re: [Caml-list] Optimizing garbage collection
Date: Sat, 20 Nov 2010 04:20:47 +0200	[thread overview]
Message-ID: <AANLkTimeHGr_z06WBeJ=MNLJUfBHJG7kp1ngcHwJZTBn@mail.gmail.com> (raw)
In-Reply-To: <4CE68FAB.6020102@elehack.net>

[-- Attachment #1: Type: text/plain, Size: 2846 bytes --]

The program I am testing it on is basically a DFS algorithm so it doesn't
use much heap memory really. Just a lot of transient objects.

Looking at the top the RSIZE looks to be not over 11M under OSX.

Yes, the default minor heap size was indeed too low, I've been trying to set
it to a higher value, now testing with the OCAMLRUNPARAM settings you
recommended. It did result in some speedup, but not an awful lot, it's
important to profile it as you say.

Best,

On Fri, Nov 19, 2010 at 4:54 PM, Michael Ekstrand <michael@elehack.net>wrote:

> On 11/18/2010 09:51 AM, Eray Ozkural wrote:
> > A program I wrote constructs a lot of small lists, and strings and
> > discards them. It's a search algorithm. I profiled this code and saw
> > that garbage collection takes significant time.
> >
> > In C++, we can write custom allocators to optimize the data structures
> > that cause such slowdowns. Any recommended strategies in ocaml?
>
> The OCaml garbage collector exposes a variety of tuning parameters
> through the Gc module[1] and the OCAMLRUNPARAM environment variable[2].
>  I would tweak those.  In particular, I would recommend increasing the
> minor heap size so that more of your data can be quickly discarded.  You
> can also increase the space overhead, thereby causing the GC to be less
> aggressive at the expense of higher memory usage/more waste.  Lastly, I
> often increase the heap increment to allow memory to allow the heap to
> expand more quickly, but I do not know if that will help in your case or
> not.  I have documented my practices more thoroughly at my blog[3].
>
> As I see it, the biggest gains will be by tuning your code and your
> minor heap size so that ephemeral structures never hit the major heap.
> My rule of thumb is that one "work unit", if you have such a concept,
> should fit in the minor heap.  Collecting dead structures from the minor
> heap is fast; moving a structure to the major heap only to have it be
> unreachable by the next GC cycle can cause substantial GC thrashing.
>
> You're on to a good start, though, by measuring.  I use gprof heavily as
> I tweak my code's performance.
>
> - Michael
>
> 1. http://caml.inria.fr/pub/docs/manual-ocaml/libref/Gc.html
> 2. http://caml.inria.fr/pub/docs/manual-ocaml/manual024.html#toc96
> 3. http://elehack.net/michael/blog/2010/06/ocaml-memory-tuning
>
> _______________________________________________
> Caml-list mailing list. Subscription management:
> http://yquem.inria.fr/cgi-bin/mailman/listinfo/caml-list
> Archives: http://caml.inria.fr
> Beginner's list: http://groups.yahoo.com/group/ocaml_beginners
> Bug reports: http://caml.inria.fr/bin/caml-bugs
>



-- 
Eray Ozkural, PhD candidate.  Comp. Sci. Dept., Bilkent University, Ankara
http://groups.yahoo.com/group/ai-philosophy
http://myspace.com/arizanesil http://myspace.com/malfunct

[-- Attachment #2: Type: text/html, Size: 4108 bytes --]

  parent reply	other threads:[~2010-11-20  2:20 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2010-11-18 15:51 Eray Ozkural
2010-11-19 14:54 ` [Caml-list] " Michael Ekstrand
2010-11-19 15:49   ` Eray Ozkural
2010-11-20  2:20   ` Eray Ozkural [this message]
2010-11-21 18:13     ` Alexandre Pilkiewicz
2010-11-21 19:26       ` Eray Ozkural
     [not found]       ` <577267187.967802.1290367612809.JavaMail.root@zmbs1.inria.fr>
2010-11-22 15:10         ` Damien Doligez
2010-11-22 16:27           ` Mauricio Fernandez
2010-11-22 16:42           ` Sylvain Le Gall
2010-11-22 18:07             ` [Caml-list] " Eray Ozkural
2010-11-22 21:14             ` Jon Harrop
2010-11-22 23:13               ` Eray Ozkural
2010-11-23 15:54                 ` Jon Harrop
2010-11-24 22:35                 ` Goswin von Brederlow
2010-11-22 18:38           ` [Caml-list] " John Carr
     [not found] <1832704169.1010021.1290451094930.JavaMail.root@zmbs1.inria.fr>
2010-11-23  9:48 ` Damien Doligez
2010-11-23 13:40   ` Christophe Raffalli
2010-11-23 16:43     ` Christophe Raffalli

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='AANLkTimeHGr_z06WBeJ=MNLJUfBHJG7kp1ngcHwJZTBn@mail.gmail.com' \
    --to=examachine@gmail.com \
    --cc=caml-list@yquem.inria.fr \
    --cc=michael@elehack.net \
    /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).