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

[ Message by date: previous | next ] [ Message in thread: previous | next ] [ Thread: previous | next ]
Date: -- (:)
From: Markus Mottl <markus.mottl@g...>
Subject: Re: [Caml-list] Strange performance bug
On Wed, Apr 29, 2009 at 15:19, Brighten Godfrey <pbg@cs.berkeley.edu> wrote:
> You seem to have solved my problem.  But out of curiosity:  Do you know how
> the GC settings in the Str library differ from PCRE's, and why?  Why does
> PCRE need to explicitly trigger GCs at all?

Str regular expressions are pure OCaml-values, whereas PCRE regexps
are allocated on the C-heap.  Since C-heap values need to be
deallocated explicitly, a finalizer has to be installed that does the
job if the OCaml-value is not reachable anymore.  The OCaml-runtime
needs hints about how large these C-values are.  Otherwise it may not
scan the OCaml-heap aggressively enough, leaving a lot of those
C-values floating around and eating up your memory.

Right now the PCRE-library guarantees that not more than 500 regular
expressions will float around at any one time.  This can lead to
considerable slowdowns if your OCaml-heap is large and you allocate
regular expressions at very high rates.

Regards,
Markus

-- 
Markus Mottl        http://www.ocaml.info        markus.mottl@gmail.com