caml-list - the Caml user's mailing list
 help / color / mirror / Atom feed
From: Brighten Godfrey <pbg@cs.berkeley.edu>
To: Markus Mottl <markus.mottl@gmail.com>
Cc: OCaml List <caml-list@yquem.inria.fr>
Subject: Re: [Caml-list] Strange performance bug
Date: Tue, 28 Apr 2009 21:31:21 -0700	[thread overview]
Message-ID: <59BD1B3A-B449-4963-9910-ED5E755D00E6@cs.berkeley.edu> (raw)
In-Reply-To: <f8560b80904282037t61b27ce7lbe532b0f2dd54ee9@mail.gmail.com>

On Apr 28, 2009, at 8:37 PM, Markus Mottl wrote:
> On Tue, Apr 28, 2009 at 22:43, Brighten Godfrey  
> <pbg@cs.berkeley.edu> wrote:
>> I've encountered a very odd performance problem which I suspect is  
>> not a bug
>> in my code.  Could 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 = Pcre.regexp "...") and pass it in with label "~rex" to
> solve this problem.


I can't see how this explains the problem.  Why should the parsing get  
dramatically slower when starting to parse the file a *second* time?

(Changing to the precompiled regexp does make this bug go away -- but  
so do many other small changes, like commenting out the last line of  
the code, *after* the parsing is complete.)

Thanks very much,
~Brighten


  reply	other threads:[~2009-04-29  4:31 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2009-04-29  2:43 Brighten Godfrey
2009-04-29  3:37 ` [Caml-list] " Markus Mottl
2009-04-29  4:31   ` Brighten Godfrey [this message]
2009-04-29  6:18     ` Alain Frisch
2009-04-29  6:27       ` Brighten Godfrey
2009-04-29  6:37         ` Alain Frisch
2009-04-29  8:29           ` Brighten Godfrey
2009-04-29 13:58             ` Markus Mottl
2009-04-29 14:48               ` Damien Doligez
2009-04-29 16:03                 ` Markus Mottl
2009-04-29 19:19                   ` Brighten Godfrey
2009-04-29 19:38                     ` Markus Mottl
2009-04-29 20:23                       ` Brighten Godfrey

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=59BD1B3A-B449-4963-9910-ED5E755D00E6@cs.berkeley.edu \
    --to=pbg@cs.berkeley.edu \
    --cc=caml-list@yquem.inria.fr \
    --cc=markus.mottl@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).