Bug #81243 [Com]: Too much memory is allocated for the return value of preg_replace

From: Date: Tue, 07 Sep 2021 17:12:03 +0000
Subject: Bug #81243 [Com]: Too much memory is allocated for the return value of preg_replace
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-236447@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=81243&edit=1 ID: 81243 Comment by: nospam at briat dot org Reported by: abecker at mailbox dot org Summary: Too much memory is allocated for the return value of preg_replace Status: Closed Type: Bug Package: PCRE related Operating System: Linux PHP Version: 8.0.8 Assigned To: cmb Block user comment: N Private report: N New Comment: I open the issue #81424. It could also be relarted to the PCRE version. Previous Comments: ------------------------------------------------------------------------ [2021-09-06 17:45:44] nikic@php.net It would be great if you could also share the script you're benchmarking (or some reduced version). ------------------------------------------------------------------------ [2021-09-06 17:13:54] cmb@php.net Thanks for reporting! Since the commit has already shipped (PHP 7.4.22 and 8.0.9), please open a new bug ticket, so we can properly track the regression. ------------------------------------------------------------------------ [2021-09-06 17:02:24] nospam at briat dot org Since this fix preg_replace seems much slower (up to 100 times). I notice by debuging the https://www.drupal.org/project/advagg module for Drupal 7 which use this cssmin.php v2.4.8-4. By using xdebug profiler I discover that this lib uses intensively preg_replace which use 99% of the total time. I made small script that call the lib and compress a css file, here's the total time in seconds with the two version of PHP. 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 0.19343304634094s 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 11.722915887833s ------------------------------------------------------------------------ [2021-07-12 16:39:34] git@php.net Automatic comment on behalf of cmb69 Revision: https://github.com/php/php-src/commit/a6b43086e6799eedf02d36ccea103e2b10c1005a Log: Fix #81243: Too much memory is allocated for preg_replace() ------------------------------------------------------------------------ [2021-07-12 11:25:23] cmb@php.net The following pull request has been associated: Patch Name: Fix #81243: Too much memory is allocated for preg_replace() On GitHub: https://github.com/php/php-src/pull/7231 Patch: https://github.com/php/php-src/pull/7231.patch ------------------------------------------------------------------------ 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=81243 -- Edit this bug report at https://bugs.php.net/bug.php?id=81243&edit=1

« previous php.bugs (#236447) next »