Bug #81424 [Ver]: PCRE2 10.35 JIT performance regression
| From: | nospam at briat dot org | Date: | Wed, 08 Sep 2021 13:47:02 +0000 |
| Subject: | Bug #81424 [Ver]: PCRE2 10.35 JIT performance regression | ||
| References: | 1 | Groups: | php.bugs |
| Request: | Send a blank email to php-bugs+get-236466@lists.php.net to get a copy of this message | ||
Edit report at https://bugs.php.net/bug.php?id=81424&edit=1
ID: 81424
User updated by: nospam at briat dot org
Reported by: nospam at briat dot org
Summary: PCRE2 10.35 JIT performance regression
Status: Verified
Type: Bug
Package: PCRE related
Operating System: *
PHP Version: 7.4
Assigned To: cmb
Block user comment: N
Private report: N
New Comment:
Thanks for the analysis.
I will also fill an issue on https://github.com/tubalmartin/YUI-CSS-compressor-PHP-port.
Previous Comments:
------------------------------------------------------------------------
[2021-09-08 12:34:28] cmb@php.net
Anyhow, I filed <https://github.com/PhilipHazel/pcre2/issues/16>.
------------------------------------------------------------------------
[2021-09-08 12:16:29] cmb@php.net
Simpler reproducer:
<?php
$data = file_get_contents("lorem.css.txt");
$time_start = hrtime(true);
var_dump(preg_match('/[^{};\/\n]+\{\}/S', $data));
var_dump(
strlen($data),
(hrtime(true) - $time_start) / 100000
);
?>
Yields a performance regression by more than factor 100 for me.
I'm not sure, though, whether the PCRE2 maintainers would fix
this, since the regex appears to be suboptimal. Using a look
behind assertion
var_dump(preg_match('/(?<![{};\/\n]+)\{\}/S', $data));
instead, makes almost no performance difference.
------------------------------------------------------------------------
[2021-09-08 11:09:59] cmb@php.net
I can confirm the serious performance regression, and that it is
caused by the update to PCRE2 10.35. The issue persists with
current master, which has PCRE2 10.37. It is possible that the
issue has been fixed in PCRE2 10.38-RC1, but I haven't verified
that yet. Just in case the issue has not been fixed upstream,
we'd need a simpler reproducer before reporting upstream.
------------------------------------------------------------------------
[2021-09-08 10:07:59] cmb@php.net
The regression can't be related to #81243, because that is only
fixed as of PHP 7.4.22. It is more likely that it is related
to the PCRE version update.
> Could you please provide the CSS file you used for testing?
Yes, please. And don't post it here in the bug tracker, but rather
put it on gist.github.com or so, and post the link here.
------------------------------------------------------------------------
[2021-09-08 10:05:34] nospam at briat dot org
here a sample css file (not valid) :
https://pastebin.com/WVBR4f9T
Results on my computer :
⯠docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w
/usr/src/myapp php:7.4.11-cli-alpine php test.php
Size: 17709bytes, duration: 0.0039818286895752s.
⯠docker run -it --rm --name my-running-script -v "$PWD":/usr/src/myapp -w
/usr/src/myapp php:7.4.12-cli-alpine php test.php
Size: 17709bytes, duration: 0.25268316268921s.
------------------------------------------------------------------------
The remainder of the comments for this report are too long. To view
the rest of the comments, please view the bug report online at
https://bugs.php.net/bug.php?id=81424
--
Edit this bug report at https://bugs.php.net/bug.php?id=81424&edit=1