Version française
Home     About     Download     Resources     Contact us    
Browse thread
Profiling garbage
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Jon Harrop <jon@f...>
Subject: Profiling garbage

I've recently been trying to optimise Presenta. The profiling results 
surprised me. Most of the time was spent in the GC, invoked by 
"<spontaneous>". I assumed this meant that the GC was recycling enormous 
amounts of garbage from the old generation. Had it been recycled from the 
young generation then I assume the calls to the (minor) GC would be invoked 
by the allocating function - is that right?

Anyway, the best way I found to track down the offending function was to write 
lots of extra code to spew out Gc.stat results and look at the amount of data 
being allocated by each function call. Doing this by hand is very tedious, of 
course. So I'm wondering, are there any tools to profile allocation and 
collection on a per function basis for OCaml code? I'm thinking of something 
along the lines of gprof results but showing space rather than time taken.

I managed to find the offending function by hand this time - it was 
retypesetting the entire document every frame, regenerating the scene graph. 
Memoizing it improved the performance of the whole program by an order of 
magnitude. So this is definitely an optimisation trick worth remembering...

-- 
Dr Jon D Harrop, Flying Frog Consultancy Ltd.
Objective CAML for Scientists
http://www.ffconsultancy.com/products/ocaml_for_scientists