Version française
Home     About     Download     Resources     Contact us    
Browse thread
Re: [Caml-list] Optimizing garbage collection
[ Home ] [ Index: by date | by threads ]
[ Search: ]

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Christophe Raffalli <christophe.raffalli@u...>
Subject: Re: [Caml-list] Optimizing garbage collection
Le 23/11/2010 14:40, Christophe Raffalli a écrit :
> 
> Hello,
> 
> May be running a minimisation algorithm to minimize (promoted_words per
> minor collection / minor_heap_size)  Could be good ?
> 

This was stupid has it converges toward zero when we increase minor_heap_size.

However, the following piece of code worked well for PML benchmark (4'30" became 3'02") :
(remark that HALVING the minor_heap_size does occur too)

I really do not know if such strategy is reasonnable as a default ?
If the 0.10 and 0.005 in the code are any reasonnable ?

-------------------8<---------------------
open Gc

let param = get ()

let old_promoted_words = ref 0.0
let old_minor_collections = ref 0
let minor_heap_size = ref param.minor_heap_size

let _ = create_alarm (fun () ->
  let s = quick_stat () in
  let promoted_words = s.promoted_words in
  let minor_collections = s.minor_collections in
  let delta_promoted_words = promoted_words -. !old_promoted_words in
  let delta_minor_collections = minor_collections - !old_minor_collections in
  old_promoted_words := promoted_words;
  old_minor_collections := minor_collections;
  let ratio = delta_promoted_words /. (float) delta_minor_collections
                                   /. (float) !minor_heap_size
  in
  if ratio > 0.10 then begin
    minor_heap_size := !minor_heap_size * 2;
(*  Printf.fprintf stderr "MHS DOUBLED <- %d (ratio %f)\n" !minor_heap_size ratio;
    flush stderr; *)
    set { get () with minor_heap_size = !minor_heap_size }
  end else if ratio < 0.005 then begin
    minor_heap_size := max 32768 (!minor_heap_size / 2);
(*  Printf.fprintf stderr "MHS HALFED <- %d (ratio %f)\n" !minor_heap_size ratio;
    flush stderr; *)
    set { get () with minor_heap_size = !minor_heap_size }
  end)
-------------------8<---------------------

-- 
Christophe Raffalli
Universite de Savoie
Batiment Le Chablais, bureau 21
73376 Le Bourget-du-Lac Cedex

tel: (33) 4 79 75 81 03
fax: (33) 4 79 75 87 42
mail: Christophe.Raffalli@univ-savoie.fr
www: http://www.lama.univ-savoie.fr/~RAFFALLI
---------------------------------------------
IMPORTANT: this mail is signed using PGP/MIME
At least Enigmail/Mozilla, mutt or evolution
can check this signature. The public key is
stored on www.keyserver.net
---------------------------------------------