The following code builds a large alternation regex which on 5.10.0 should cause demerphq's cool tries code to kick in, and it seems to. When I specify 13,104 alternations, it can search a 1MB string in under 3 seconds which is very impressive. However, if I increase it by one alternation to 13,105, it suddenly goes pathelogical and takes 646 seconds to complete the same task.

The alternations I am using are 10-chars giving an array size of 13,105 * 10 + internals ~= 128k. This number rings a bell. I seem to recall that this is the magic number at which memory allocations bypass the normal allocation mechanism and go straight to allocating virtual memory? I've done a cursory grep of the sources trying to confirm this without success. Does anyone know anything about it?

It would also be useful to know if 5.10 builds other than AS1000 are similarly affected. If anyone with such a build has the time to try this out for me, the required command line options are shown after the __END__ token below:

#! perl -slw use strict; $|++; srand 1; sub rndStr{ join'', @_[ map{ rand @_ } 1 .. shift ] } our $N ||= 1000; our $S ||= 30e6; my $chrom = chr(0) x $S; substr( $chrom, $_, 1, ('A', 'C', 'G', 'T' )[ rand 4 ] ) for 0 .. $S-1 +; my @probes = map rndStr( 10, 'A', 'C', 'G', 'T' ), 0 .. $N; warn "Trying $N probes with perl $]"; warn time; my $re = join '|', @probes[ 0 .. $N ]; $re = qr[$re]; printf "$-[ 0 ] : '$1'\n" while $chrom =~ m[($re)]g; print "\n"; warn time; __END__ C:\test>\Perl510\bin\perl5.10.0.exe -s 668954.p10 -S=1e6 -N=13104 | wc + -l Trying 13104 probes with perl 5.010000 at 668954.p10 line 18. 1203549864 at 668954.p10 line 20. 1203549867 at 668954.p10 line 27. 11282 C:\test>\Perl510\bin\perl5.10.0.exe -s 668954.p10 -S=1e6 -N=13105 | wc + -l Trying 13105 probes with perl 5.010000 at 668954.p10 line 18. 1203549872 at 668954.p10 line 20. 1203550518 at 668954.p10 line 27. 11282

Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
"Science is about questioning the status quo. Questioning authority".
In the absence of evidence, opinion is indistinguishable from prejudice.
"Too many [] have been sedated by an oppressive environment of political correctness and risk aversion."

In reply to 5.10.0 regex slowdown by BrowserUk

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.