From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.1.3 (2006-06-01) on yquem.inria.fr X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=none autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from nez-perce.inria.fr (nez-perce.inria.fr [192.93.2.78]) by yquem.inria.fr (Postfix) with ESMTP id 41391BC29 for ; Tue, 29 Aug 2006 06:16:44 +0200 (CEST) Received: from mtaout-w.tc.umn.edu (mtaout-w.tc.umn.edu [160.94.160.21]) by nez-perce.inria.fr (8.13.6/8.13.6) with ESMTP id k7T4Ghhm030017 for ; Tue, 29 Aug 2006 06:16:43 +0200 Received: from [128.101.106.92] (glu02.cs.umn.edu [128.101.106.92]) by mtaout-w.tc.umn.edu with ESMTP for caml-list@yquem.inria.fr; Mon, 28 Aug 2006 23:16:40 -0500 (CDT) X-Umn-Remote-Mta: [N] glu02.cs.umn.edu [128.101.106.92] #+LO+TS+AU+HN Message-ID: <44F3BFA7.20202@cs.umn.edu> Date: Mon, 28 Aug 2006 23:16:39 -0500 From: Christopher Kauffman User-Agent: Mozilla Thunderbird 1.0.8 (X11/20060725) X-Accept-Language: en-us, en MIME-Version: 1.0 To: caml-list@yquem.inria.fr Subject: Garbage collection and caml_adjust_gc_speed Content-Type: text/plain; charset=ISO-8859-1; format=flowed Content-Transfer-Encoding: 7bit X-Miltered: at nez-perce with ID 44F3BFAB.000 by Joe's j-chkmail (http://j-chkmail.ensmp.fr)! X-Spam: no; 0.00; ocaml:01 computations:01 bigarray:01 lacaml:01 ocaml:01 bigarray:01 lacaml:01 stub:01 alloc:01 runtime:01 cheers:01 0.01:98 cumulative:98 2.94:98 2.01:98 I am finishing up my first major research application written in OCaml. The code is a scientific application which does a moderate amount of floating point computations for which I have employed the Bigarray library and the Lacaml package. I am attempting to tune the performance of the code and to that end, I have examined the native code performance using gprof (OCaml manual section 17.4). The first thing that struck me on analyzing the profile is that the function 'caml_adjust_gc_speed' is called a lot. The first few lines of the profile are: Flat profile: Each sample counts as 0.01 seconds. % cumulative self self total time seconds seconds calls s/call s/call name 14.55 6.80 6.80 4841768 0.00 0.00 caml_adjust_gc_speed 14.41 13.53 6.73 bigarray_fill 6.87 16.74 3.21 lacaml_Dssqr_zero_stub 6.30 19.68 2.94 bigarray_offset 4.30 21.69 2.01 bigarray_slice 4.03 23.57 1.88 bigarray_get_N 2.68 24.82 1.25 1612 0.00 0.00 sweep_slice 2.63 26.05 1.23 24714254 0.00 0.00 caml_c_call 2.10 27.03 0.98 4972572 0.00 0.00 caml_alloc_shr ... The actual runtime of the program is about 18 seconds so the gprof cumulative time is off by quite a bit. What concerns me is the large overhead I seem to be getting from the first function, 'caml_adjust_gc_speed', which I assume is related to the garbage collector. Over 4 million calls to this function seems a little much. I attempted to play with a garbage collection parameter, the value of control.space_overhead in the Gc module. According to the manual, this affects the major GC speed and increasing the value is supposed to cut down on the aggressiveness of the GC. Setting space_overhead to 99 did not change number of calls to 'caml_adjust_gc_speed'. I'm looking for someone with a bit more knowledge of the garbage collection in OCaml to enlighten me on whether this overhead can be reduced or if it is an unavoidable side-effect of relying on the garbage collector. I'd be happy to provide more details on the code if this would be helpful. Cheers, Chris