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_oldify_local_roots takes 50% of the total runtime
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: 2006-10-25 (15:49)
From: Hendrik Tews <H.Tews@c...>
Subject: caml_oldify_local_roots takes 50% of the total runtime

I have an application (olmar[1]) for gprof tells me 

Each sample counts as 0.01 seconds.
  %   cumulative   self              self     total           
 time   seconds   seconds    calls   s/call   s/call  name    
 58.33      9.52     9.52                             caml_oldify_local_roots

that is more than half of the time is spent in
caml_oldify_local_roots. The trouble is, there is no significant
garbage to collect. If I could, I would switch off garbage
collection completely.

The ocaml part of the application takes a big tree (353040 nodes
in the profiled case) in C++ and translates it into ocaml. Some
nodes are shared in the tree and there are also circles,
therefore, every C++ node has caml_global_root for its ocaml
relative (so 350.000 caml_global_roots). When the ocaml tree is
ready it is marshaled to disk and the application exits (no need
to collect garbage).

To improve the runtime I set space_overhead to max_int, but this
didn't change much (profiling above is with max_int). Apparently,
space_overhead doesn't have really have an influence on
allocate-only programs. Finally I increase minor_heap_size until
the minor collections came down to one. This brought the ocaml
running time down from 5.7s to 1.3s. 

Is there a way to adopt the size of minor heap to the program
behaviour? (BTW 32K default minor heap sounds like 1995, not like

>From the comments of Damien Doligez in a related thread in
I got the impression that there is extra punishment for
caml_local_roots. Should the situation improve if I organize the
350.000 ocaml node pointers on the ocaml side via one local root
(asumming this information is needed not so often)?