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.9 required=5.0 tests=AWL,DNS_FROM_RFC_POST, SPF_NEUTRAL autolearn=disabled version=3.1.3 X-Original-To: caml-list@yquem.inria.fr Delivered-To: caml-list@yquem.inria.fr Received: from mail2-relais-roc.national.inria.fr (mail2-relais-roc.national.inria.fr [192.134.164.83]) by yquem.inria.fr (Postfix) with ESMTP id F4169BC37 for ; Wed, 29 Apr 2009 05:37:10 +0200 (CEST) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: AhsJADto90nRVdypdWdsb2JhbACDAJMvPwEMCgsHEaUvgQiQYAEDAQODcAWHcw X-IronPort-AV: E=Sophos;i="4.40,264,1238968800"; d="scan'208";a="25331920" Received: from mail-fx0-f169.google.com ([209.85.220.169]) by mail2-smtp-roc.national.inria.fr with ESMTP; 29 Apr 2009 05:37:10 +0200 Received: by fxm17 with SMTP id 17so1176061fxm.27 for ; Tue, 28 Apr 2009 20:37:10 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=gamma; h=domainkey-signature:mime-version:received:in-reply-to:references :date:message-id:subject:from:to:cc:content-type :content-transfer-encoding; bh=doPQ0HtsHdpu6UOwr1PKlGPtJvBirOsEW7FHh2kbqUE=; b=Cq8U17/01RJYy4yvlhpyBCWbGzQfOR92f3BYxDbngI/vgF7zUJag+wDq7WrCemcYin XdLdx5HzHrzJXfL5Nkb1zpArRKv4ppVG/msy4H8Qw7VALSeS7l4zcCiTMZVNGwho+LoB G7SNY14yuflO5qHjtIBP2qyuQBW77G9i+Rmd4= DomainKey-Signature: a=rsa-sha1; c=nofws; d=gmail.com; s=gamma; h=mime-version:in-reply-to:references:date:message-id:subject:from:to :cc:content-type:content-transfer-encoding; b=NwYmK9CZLz6V7i6DMb60Gh4XcmQHn3YL5h+IF1QaAn61VDFgmJ98Kp9CuC9F/rwdIj uvwSR+Hvl1xKVctR7cDNi0hI0ALCVL42EKZAEjlLrpW53Q9GV0CnFV/v/CZCECYnlJvd phtHmR9xdHJXJ6uIAqi8lKBv+17Rj3sMNqo8Q= MIME-Version: 1.0 Received: by 10.86.68.1 with SMTP id q1mr224774fga.34.1240976229363; Tue, 28 Apr 2009 20:37:09 -0700 (PDT) In-Reply-To: <324B24CA-9671-42C0-B722-C7710C0C45C7@cs.berkeley.edu> References: <324B24CA-9671-42C0-B722-C7710C0C45C7@cs.berkeley.edu> Date: Tue, 28 Apr 2009 23:37:09 -0400 Message-ID: Subject: Re: [Caml-list] Strange performance bug From: Markus Mottl To: Brighten Godfrey Cc: caml-list@yquem.inria.fr Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable X-Spam: no; 0.00; bug:01 markus:01 mottl:01 markus:01 mottl:01 bug:01 compiler:01 pcre:01 pcre:01 regexp:01 ocaml:01 28,:98 2009:98 wrote:01 pat:01 On Tue, Apr 28, 2009 at 22:43, Brighten Godfrey wrote= : > I've encountered a very odd performance problem which I suspect is not a = bug > in my code. =A0Could it be the compiler, or maybe PCRE? I'm not sure it solves your problem (haven't tried the example), but just looking at the code there is clearly a performance bug: the pattern is passed to Pcre.pmatch "on the fly" using label "~pat". This is ok and convenient if it is used only once, but is bad if it happens in a loop. Precompile the regular expression outside of the loop (let rex =3D Pcre.regexp "...") and pass it in with label "~rex" to solve this problem. Regards, Markus --=20 Markus Mottl http://www.ocaml.info markus.mottl@gmail.com