Skip to content

Instantly share code, notes, and snippets.

@kraih
Last active August 29, 2015 14:04
Show Gist options
  • Save kraih/d98457537a07a46e753f to your computer and use it in GitHub Desktop.
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"
@mgruberman
Copy link

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

@kraih
Copy link
Author

kraih commented Jul 15, 2014

@kraih
Copy link
Author

kraih commented Jul 15, 2014

For Mojo::DOM the performance decrease was about 30% with Perl 5.20, which we now mitigate by using /o.

@rurban
Copy link

rurban commented Jul 15, 2014

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

@kraih
Copy link
Author

kraih commented Jul 16, 2014

@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"

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment