Hi All,
I did a quick benchmark test on his code using non threaded 5.8.0 and 5.6.1 and indeed there is a serious performance degradation.

It is the combination of the i and the g regex modifiers that causes the performance issue. If you remove one of them the performance is the sames as in 5.6.1. I did't not dig deeper into this, but there must be an explanation for this.

ps: this is the code I used

#!/usr/local/bin/perl5.8.0 or #!/usr/local/bin/perl5.6.1 use Benchmark; $main::x=join("",(a..z))x100; &timethis(100,\&test); sub test { $main::x =~ s/(.*?)I/$1/isge; }
update On popular demand, here are the benchmark results.
Perl 5.8.0 timethis 1000: 48 wallclock secs (46.76 usr + 0.02 sys = 46.78 CPU) @ + 21.38/s (n=1000) Perl 5.6.1 timethis 1000: 1 wallclock secs ( 0.70 usr + 0.00 sys = 0.70 CPU) @ + 1428.57/s (n=1000)
When debugging with use re "debug", there are some differences (I only post the last few lines) In 5.8.0, it gives
Setting an EVAL scope, savestack=12 24 <opqrstuvwx> <yz> | 1: OPEN1 24 <opqrstuvwx> <yz> | 3: MINMOD 24 <opqrstuvwx> <yz> | 4: STAR Setting an EVAL scope, savestack=12 failed... Setting an EVAL scope, savestack=12 25 <opqrstuvwxy> <z> | 1: OPEN1 25 <opqrstuvwxy> <z> | 3: MINMOD 25 <opqrstuvwxy> <z> | 4: STAR Setting an EVAL scope, savestack=12 failed... Setting an EVAL scope, savestack=12 26 <opqrstuvwxyz> <> | 1: OPEN1 26 <opqrstuvwxyz> <> | 3: MINMOD 26 <opqrstuvwxyz> <> | 4: STAR Setting an EVAL scope, savestack=12 failed... Match failed
whilst in 5.6.1, it returns
SANY can match 1 times out of 1... 23 <opqrstuvw> <xyz> | 6: CLOSE1 23 <opqrstuvw> <xyz> | 8: EXACTF <I> failed... SANY can match 1 times out of 1... 24 <opqrstuvwx> <yz> | 6: CLOSE1 24 <opqrstuvwx> <yz> | 8: EXACTF <I> failed... SANY can match 1 times out of 1... 25 <opqrstuvwxy> <z> | 6: CLOSE1 25 <opqrstuvwxy> <z> | 8: EXACTF <I> failed... SANY can match 1 times out of 1... 26 <opqrstuvwxyz> <> | 6: CLOSE1 26 <opqrstuvwxyz> <> | 8: EXACTF <I> failed... SANY can match 0 times out of 1... failed... Match failed
But, since I am not a regex expert, I have no clue what this means :-)
---------------------------
Dr. Mark Ceulemans
Senior Consultant
BMC, Belgium

In reply to Re: serious regex performance degradation after upgrade to perl 5.8 from 5.6 by mce
in thread serious regex performance degradation after upgrade to perl 5.8 from 5.6 by dmandel

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.