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=1.5 required=5.0 tests=SPF_SOFTFAIL autolearn=disabled version=3.1.3 Received: from mail3-relais-sop.national.inria.fr (mail3-relais-sop.national.inria.fr [192.134.164.104]) by yquem.inria.fr (Postfix) with ESMTP id 50C05BC37 for ; Wed, 29 Apr 2009 22:23:46 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: Ah8BAARU+Emp5TxXkWdsb2JhbACWaAEBAQEJCwoHEQWoM4gliE2DdQU X-IronPort-AV: E=Sophos;i="4.40,268,1238968800"; d="scan'208";a="26999593" Received: from gateway0.eecs.berkeley.edu ([169.229.60.87]) by mail3-smtp-sop.national.inria.fr with ESMTP/TLS/DHE-RSA-AES256-SHA; 29 Apr 2009 22:23:45 +0200 Received: from ragtime.research.intel-research.net (bldmz-nat-161-164.berkeley.intel-research.net [12.155.161.164]) (authenticated bits=0) by gateway0.EECS.Berkeley.EDU (8.14.3/8.13.5) with ESMTP id n3TKNdi5018959 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT); Wed, 29 Apr 2009 13:23:40 -0700 (PDT) Cc: OCaml List Message-Id: <55B43ABC-5EC3-4277-BFED-7151AA05B972@cs.berkeley.edu> From: Brighten Godfrey To: Markus Mottl In-Reply-To: Content-Type: text/plain; charset=US-ASCII; format=flowed; delsp=yes Content-Transfer-Encoding: 7bit Mime-Version: 1.0 (Apple Message framework v930.3) Subject: Re: [Caml-list] Strange performance bug Date: Wed, 29 Apr 2009 13:23:34 -0700 References: <324B24CA-9671-42C0-B722-C7710C0C45C7@cs.berkeley.edu> <59BD1B3A-B449-4963-9910-ED5E755D00E6@cs.berkeley.edu> <49F7F135.5080504@gmail.com> <08C6A0FC-90F2-43A4-AB78-4A3B68291FAA@cs.berkeley.edu> <49F7F59B.7070204@frisch.fr> <6D9C5A68-1874-4BBC-AE3D-9CCC3614AF7C@cs.berkeley.edu> <0FDD87FB-2461-4BBC-BDB1-5316A5AE4D23@inria.fr> <25CD1992-3F33-4AEA-97A3-EC54729EC4FE@cs.berkeley.edu> X-Mailer: Apple Mail (2.930.3) X-Spam: no; 0.00; bug:01 markus:01 mottl:01 pcre:01 ocaml-values:01 pcre:01 regexps:01 deallocated:01 finalizer:01 ocaml-value:01 ocaml-heap:01 pcre-library:01 ocaml-heap:01 2009:98 eating:98 On Apr 29, 2009, at 12:38 PM, Markus Mottl wrote: > On Wed, Apr 29, 2009 at 15:19, Brighten Godfrey > 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. Got it. Thank you all for your replies! ~Brighten