develooper Front page | perl.perl5.porters | Postings from April 2011

Re: [perl #76546] regex engine slowdown bug

Thread Previous
April 1, 2011 02:03
Re: [perl #76546] regex engine slowdown bug
Message ID:
On 1 April 2011 10:57, David Leadbeater <> wrote:
> On Thu, Mar 31, 2011 at 03:05:52AM -0700, Alex Efros via RT wrote:
> [..]
>> P.S. I hope one lucky day we'll find libre2 support in perl, using some
>> pragma to switch between current perl regexp engine and libre2 - they
>> are mostly compatible, but libre2 guarantee constant execution time and
>> I'm really tired of regexps which at some moment decide to spend few
>> minutes for execution instead of nanoseconds.
> Not wanting to hijack this bug's thread but see
> (feel free to let me
> know if you have issues).
Many alternatives

Matching a string against a regexp with 17,576 alternatives (aaa .. zzz).

This uses trie matching on Perl (obviously RE2 does similar by default).

  $ perl misc/
          Rate   re  re2
  re   52631/s   -- -91%
  re2 554938/s 954%   --

This one is frustrating. We have to consider a lot of cases that RE2 doesnt.

Nevertheless, we should be able to speed this up considerably. For
various reasons we chose an implementation that was designed to handle
an uncommon worse case scenario, and not the common one, and pay for
it in terms of speed.


perl -Mre=debug -e "/just|another|perl|hacker/"

Thread Previous Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at | Group listing | About