-
-
Save kraih/d98457537a07a46e753f to your computer and use it in GitHub Desktop.
$ perl5.16 -Mre=debug -E 'my $x = "y"; "y" =~ /z$x/ for 1 .. 2' | |
Compiling REx "zy" | |
Final program: | |
1: EXACT <zy> (3) | |
3: END (0) | |
anchored "zy" at 0 (checking anchored isall) minlen 2 | |
Freeing REx: "zy" |
$ perl5.20 -Mre=debug -E 'my $x = "y"; "y" =~ /z$x/o for 1 .. 2' | |
Compiling REx "zy" | |
Final program: | |
1: EXACT <zy> (3) | |
3: END (0) | |
anchored "zy" at 0 (checking anchored isall) minlen 2 | |
Freeing REx: "zy" |
$ perl5.20 -Mre=debug -E 'my $x = "y"; "y" =~ /z$x/ for 1 .. 2' | |
Compiling REx "zy" | |
Final program: | |
1: EXACT <zy> (3) | |
3: END (0) | |
anchored "zy" at 0 (checking anchored isall) minlen 2 | |
Compiling REx "zy" | |
Freeing REx: "zy" |
The runtime ought to be doing a strEQ of "zy" vs "zy" each and every time but retaining the compiled object between invocations. Is that not what's going on
@wolfsage has bisected it to this commit. http://perl5.git.perl.org/perl.git/commitdiff/9f141731d83a1ac6294a5580a5b11ff41490309a
For Mojo::DOM
the performance decrease was about 30% with Perl 5.20, which we now mitigate by using /o
.
It's the "detection of unchanged pattern" change, which "broke" 5.20.
But it's not really broken, just a bit worse.
It's not entirely re-compiled, the check is now just later, the 2x debug message Compiling REx "zy" is a bit misleading, qr-overloading works now, but it's slower of course. We got used to that
@rurban is right, a full recompilation looks a little different and is quite a bit slower.
$ perl5.20 -Mre=debug -E 'my $x = "y"; "y" =~ /$_$x/ for 1 .. 2'
Compiling REx "1y"
Final program:
1: EXACT <1y> (3)
3: END (0)
anchored "1y" at 0 (checking anchored isall) minlen 2
Compiling REx "2y"
Final program:
1: EXACT <2y> (3)
3: END (0)
anchored "2y" at 0 (checking anchored isall) minlen 2
Freeing REx: "1y"
Freeing REx: "2y"
No, this is not a regression. I've brought up the issue on #p5p and consensus was that the old behavior was just a lucky accident.