New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Pathological performance of a pattern match #13992
Comments
From @andkI think this bugreport deserves to be a quiz. Test your intuition. Sample string to test the regexps against: sprintf "%scould%snot%sopen%s", ("x"x10000)x4; Regexp 1: qr!.*(?:could ?not (?:open|connect|find))! Regexp 2 (the difference is it's case insensitive): qr!.*(?i:could ?not (?:open|connect|find))! Note: neither matches and this is correct. Question: which is faster and by how much? Answer: regexp 1 is much more than 100 times slower than the regexp 2. On my machine this program takes 1-2 wallclock seconds: time $p -le 'my $x = sprintf "%scould%snot%sopen%s", ("x"x10000)x4;print $x =~ m!.*(?:could ?not (?:open|connect|find))! ? "not ok" : "ok";' And on all those perls it takes less than 0.01 wallclock seconds when I Historical evidence: this is not a regression, at least not since 5.6. I Competition evidence: with 'use re::engine::PCRE;' both regexps are Enjoy, |
From @iabynOn Sat, Jul 19, 2014 at 02:21:03PM -0700, Andreas J. Koenig via RT wrote:
The second is faster because it disables intuiting, which causes it to I don't know know what the fix is, but this is tied up with how intuit() Its all a bit of a mess, and I intend to look at this properly when I get -- |
The RT System itself - Status changed from 'new' to 'open' |
I can reproduce that on 5.18.4 but I can't on 5.30.2 so it definitely was fixed at some point. |
Migrated from rt.perl.org#122331 (status was 'open')
Searchable as RT122331$
The text was updated successfully, but these errors were encountered: