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

Re: [perl #76546] regex engine slowdown bug

Thread Previous
From:
demerphq
Date:
April 1, 2011 02:03
Subject:
Re: [perl #76546] regex engine slowdown bug
Message ID:
AANLkTi=M6oQmqtYu2F7O-BTu=42L955n12o0p_Bj1CFk@mail.gmail.com
On 1 April 2011 10:57, David Leadbeater <dgl@dgl.cx> 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
> http://search.cpan.org/perldoc?re::engine::RE2 (feel free to let me
> know if you have issues).
>
<quote>
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/altern.pl
          Rate   re  re2
  re   52631/s   -- -91%
  re2 554938/s 954%   --
<quote>

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.

Cheers,
yves


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

Thread Previous


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About