Version française
Home     About     Download     Resources     Contact us    

This site is updated infrequently. For up-to-date information, please visit the new OCaml website at

Browse thread
[Caml-list] Memory management dominates running time
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Chet Murthy <chet@w...>
Subject: Re: [Caml-list] Memory management dominates running time

By using gprof, and doing a little careful counting, you can 
often find out where egregious allocations are happening, and
eliminate them.

I can't give you good pointers on this, because, well, it's a bit of
an art, and takes a lot of experience.  But it _is_ doable, and I have
done it to nontrivial programs in Caml, as well as in Java, attaining
speedups of 2x, 3x, without much code-restructuring.

E.g., once, I took a Stream-based parser, and wrote a Stream module
which only supported "char Stream", and only for parsing.

By writing a few auxiliary functions in addition to this, I was able
to reduce the consing associated with stream-based parsing (the
constant creation of "Some _" blocks) significantly, and got a rather
large speedup.

I was able to see that this was important, basically by looking around
in the gprof profile and trying to follow where the allocation were

To unsubscribe, mail Archives:
Bug reports: FAQ:
Beginner's list: