Bug #72640 [Opn->Nab]: Regexp with possessive/atomic grouping 25x slower compared to 5.6.x

From: Date: Thu, 21 Jul 2016 13:58:00 +0000
Subject: Bug #72640 [Opn->Nab]: Regexp with possessive/atomic grouping 25x slower compared to 5.6.x
References: 1  Groups: php.bugs 
Request: Send a blank email to php-bugs+get-202477@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=72640&edit=1 ID: 72640 Updated by: cmb@php.net Reported by: arjen at parse dot nl Summary: Regexp with possessive/atomic grouping 25x slower compared to 5.6.x -Status: Open +Status: Not a bug Type: Bug Package: PCRE related Operating System: Linux PHP Version: 7.0.9 -Assigned To: +Assigned To: cmb Block user comment: N Private report: N New Comment: Having a closer look at the performance result shows that PHP 7.0.1 - 7.0.5 appear to be really slow, but that current versions are not affected, so I'm closing this ticket. Previous Comments: ------------------------------------------------------------------------ [2016-07-21 13:10:25] arjen at parse dot nl Description: ------------ After reading http://stackstatus.net/post/147710624694/outage-postmortem-july-20-2016 we checked our own implementation. We did not use possessive or atomic grouping in our trim regexps, so one trim call with 20000 whitespace char and a following non-whitespace char took 6 seconds. After updating the regexp this dropped to 2 seconds. Better but still not safe enough.. So we checked the performance in different php versions on 3v4l.org and 5.6 appeared 25x faster: https://3v4l.org/SPEXB/perf#tabs Avg 0.066 for 5.6.x compared to 1.670 for 7.0.x Test script: --------------- <?php preg_replace('~(?>[\pZ\pC]+)$~u', '', str_repeat("\u{2029}", 20000) . 'x'); Expected result: ---------------- Run-time comparable to 5.6.x Actual result: -------------- 25x slowdown. ------------------------------------------------------------------------ -- Edit this bug report at https://bugs.php.net/bug.php?id=72640&edit=1

« previous php.bugs (#202477) next »