php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Bug #77095 slowness regression in 7.2/7.3 (compared to 7.1)
Submitted: 2018-11-02 13:13 UTC Modified: 2018-11-05 21:59 UTC
From: remi@php.net Assigned: ab (profile)
Status: Closed Package: PCRE related
PHP Version: 7.2.11 OS:
Private report: No CVE-ID: None
 [2018-11-02 13:13 UTC] remi@php.net
Description:
------------
When pcre.jit=1 everything is ok
With pcre.jit=0 we encounter slowness



From valgrind / kcachegrind results,
99% spent in php_pcre_math_impl (in pcre_exec for 7.2 or php_pcre2_match for 7.3)

Test script:
---------------
<?php
printf("PHP version %s\n", PHP_VERSION);
printf("pcre.jit=%d\n", ini_get('pcre.jit'));
$fd = __DIR__.'/data';
$a = str_repeat("\n", 1000000);
file_put_contents($fd, $a);
$fi = finfo_open(FILEINFO_NONE);
$t = microtime(true);
var_dump(finfo_file($fi, $fd));
printf("Time = %.4f\n", microtime(true) - $t);
finfo_close($fi);


Expected result:
----------------
PHP version 7.1.24RC1
pcre.jit=1
string(10) "ASCII text"
Time = 0.0147


Actual result:
--------------
PHP version 7.2.12RC1
pcre.jit=1
string(10) "ASCII text"
Time = 0,0172

PHP version 7.2.12RC1
pcre.jit=0
string(10) "ASCII text"
Time = 0,6555

40 times slower


PHP version 7.3.0RC4
pcre.jit=1
string(10) "ASCII text"
Time = 0.0177

PHP version 7.3.0RC4
pcre.jit=0
string(10) "ASCII text"
Time = 2.2364

126 times slower



Patches

Pull Requests

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-11-02 13:14 UTC] ab@php.net
-Assigned To: +Assigned To: ab
 [2018-11-05 21:59 UTC] ab@php.net
-Status: Assigned +Status: Closed
 [2018-11-05 21:59 UTC] ab@php.net
A fix was put to libmagic.

http://git.php.net/?p=php-src.git;a=commit;h=c621182c42a36975970586cfc294bc5a80ba08cb
http://git.php.net/?p=php-src.git;a=commit;h=7f5f46013b8a37bab6b378903aace5da9ce8dc5e

Further diff in libmagic versions might tell some difference. It seems to give an acceptable performance with the given reproduce case, though. Thus, this should be ok to close for now.

Thanks.
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Thu Nov 21 10:01:29 2024 UTC