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
Regexp performance problem with swiped strings (?) #15643
Comments
From @ntyniAs reported by Leszek Dubiel in <https://bugs.debian.org/839600>, Here's a test case: ======================================= use strict; my $s = "A"x (2**16 + 5); cmpthese(-1, {
|
From @iabynOn Mon, Oct 03, 2016 at 01:15:27PM -0700, Niko Tyni wrote:
This is down to a limitation in the COW implementation. Perl stores the The PADTMP commit is not really relevant - it just happens to alter the You can see a similar slowdown on old perls (5.16.0 and earlier) if you The whole COW/SvGROW interaction is on my list of things to do. -- |
The RT System itself - Status changed from 'new' to 'open' |
From @ntyniOn Tue, Oct 04, 2016 at 09:08:02AM +0100, Dave Mitchell wrote:
Many thanks for the explanation. Shouldn't the /n regexp modifier help |
From @leszekdubielI have tested program below for $ARGV[0] in range of 0 to 2000 (two #!/usr/bin/perl use strict; my $s = "A"x (2**16 + 5 - $ARGV[0]); cmpthese(-1, { During this long run: -- "concat" was extremely slow in 500 (five hundred) cases, -- "assing" was extremely slow for $ARGV[0] = 6, 262, 518, -- "string" was extremely slow for $ARGV[0] = 8, 264, 520, My function works on reference to big string, and here is ugly sub ... { while () { my $a = ... # big text # matching big text ... |
From @demerphqOn 29 October 2016 at 09:46, Leszek Dubiel
You have not told us your OS, or the version of Perl you are using, Can you please provide the output of perl -V, and details about your os, etc. Yves -- |
From @demerphqOn 30 October 2016 at 09:51, demerphq <demerphq@gmail.com> wrote:
Actually, playing more, I can replicate in blead on linux (low numbers $ ./perl -Ilib t.pl 0 However perl 5.18.4 does not have this issue. $ perl t.pl 0 My first guess is that this is an issue with COW and/or malloc. Yves -- |
From @demerphqOn 30 October 2016 at 09:57, demerphq <demerphq@gmail.com> wrote:
Well, it is COW, but indirectly. Modifying your test code to show more detail: $ cat t.pl use strict; my $mod = $ARGV[0] || 0; my $assign = "A"x (2**16 + 5 - $mod); print STDERR "assign\n"; cmpthese(-1, { and then running it like this: ./perl -Ilib t.pl 0 2>&1 | perl -pe's/A+/A+/g;' We get this: $ ./perl -Ilib t.pl 0 2>&1 | perl -pe's/A+/A+/g;' From which we can see that: concat Which does not leave enough room for the refcount. So a point fix Yves -- |
From @demerphqOn 30 October 2016 at 10:30, demerphq <demerphq@gmail.com> wrote:
Also, we need to remove the exemption for powers-of-2 rule, as it Yves -- |
From @demerphqOn 30 October 2016 at 11:11, demerphq <demerphq@gmail.com> wrote:
I have pushed commit fe546b3 fix #129802: sv_grow: remove the overallocation for COW exemption They are just performance bombs waiting to hit the regex engine Really this just shows the flaw in our current COW implementation. commit 7fdc4f5 fix perl #129802 - overallocate in concat to ensure we can COW Otherwise we get degenerate performance in things like the regex The first is potentially controversial. So it might get reverted. But Yves |
From @ntyniOn Sun, Oct 30, 2016 at 11:29:10AM +0100, demerphq wrote:
Many thanks for your work. Just in case you didn't notice, there was As this seems to be a performance regression in 5.20 or so (and was |
From @tonycozOn Fri, Nov 04, 2016 at 12:20:11PM +0200, Niko Tyni wrote:
If 7fdc4f5 is backported to maint then whatever fix we end up with Tony |
From @demerphqOn 4 November 2016 at 13:53, Tony Cook <tony@develop-help.com> wrote:
Unless there is some concern about the power-of-2 issue, my gut Yves -- |
From @demerphqOn 4 November 2016 at 11:20, Niko Tyni <ntyni@debian.org> wrote:
You are welcome. It is always a pleasure working with you Debian folks.
Just to repeat what I said in reply to Tony, unless the power-of-2 Yves -- |
From @iabynOn Tue, Oct 04, 2016 at 09:42:51PM +0300, Niko Tyni wrote:
No, because /n only converts some or all (..)'s into (?:...)'s. It doesn't -- |
Migrated from rt.perl.org#129802 (status was 'open')
Searchable as RT129802$
The text was updated successfully, but these errors were encountered: