Version française
Home     About     Download     Resources     Contact us    
Browse thread
Garbage collection and caml_adjust_gc_speed
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christopher Kauffman <kauffman@c...>
Subject: Re: [Caml-list] Garbage collection and caml_adjust_gc_speed - Problem in Bigarray
After some very helpful advice from Shivkumar Chandrasekaran, I have located the 
source of the problem. In my code, a very frequent operation is to take a slice 
of a matrix or array (a column of a matrix representing the X-coordinates of 
some atoms for instance) and perform some operations on that slice. This is 
supported in the Bigarray library with the 'slice_left' function (for 
fortran_layout arrays) and in Lacaml with Mat.col function. Unfortunately, using 
this operation results in the following sequence of underlying C-function calls 
in ocaml-3.09.2/otherlibs/bigarray/bigarray_stubs.c:

bigarray_slice() -> alloc_bigarray() -> alloc_custom() -> caml_adjust_gc_speed()

So even though there is no allocation of new underlying data, taking a slice 
creates custom data to manage the new alias which triggers GC adjustment. I am 
certainly not familiar with the inner workings of the garbage collector, but 
this seems like undesirable behavior as much efficiency is lost for no apparent 
reason.

This now seems like an issue with the Bigarray library. Please advise me on the 
protocol for submitting this issue that it might be considered for correction in 
a future release.

Cheers,
Chris

PS - Thanks again to Shivkumar!