Bug #74250 [NEW]: OPcache compilation performance regression in PHP 5.6/7 with huge classes
| From: | dzuelke at gmail dot com | Date: | Wed, 15 Mar 2017 09:36:21 +0000 |
| Subject: | Bug #74250 [NEW]: OPcache compilation performance regression in PHP 5.6/7 with huge classes | ||
| Groups: | php.bugs | ||
| Request: | Send a blank email to php-bugs+get-207848@lists.php.net to get a copy of this message | ||
From: dzuelke at gmail dot com
Operating system: Linux
PHP version: 7.0.16
Package: opcache
Bug Type: Bug
Bug description:OPcache compilation performance regression in PHP 5.6/7 with huge classes
Description:
------------
There appears to be a performance regression in the CFG and DFA based
optimization passes of OPcache in PHP 5.6+ when loading huge classes
(such as those generated by Symfony's routing component) for the first
time.
The issue does not occur on PHP 5.5. Tests below are with 5.6.30, 7.0.16
and 7.1.2 and default INI settings; I replicated the issue on both macOS
and Linux.
Test file here (it's from an actual application, slightly anonymized,
not a synthetic example):
https://gist.github.com/dzuelke/fe867f55f09e0bf79ecefcc815b7fe92
Without OPcache, everything is fine in all versions:
$ time -p php -dopcache.enable_cli=0 hugeclass.php
real 0.10
user 0.09
sys 0.00
With OPcache on, things are suddenly much, much slower:
5.6:
$ time -p php -dopcache.enable_cli=1 hugeclass.php
real 3.23
user 3.21
sys 0.02
7.0:
$ time -p php -dopcache.enable_cli=1 hugeclass.php
real 1.76
user 1.73
sys 0.02
7.1:
$ time -p php -dopcache.enable_cli=1 hugeclass.php
real 4.01
user 3.98
sys 0.02
For comparison, 5.5 is as speedy as you'd expect it to be:
$ time -p php -dopcache.enable_cli=1 hugeclass.php
real 0.14
user 0.11
sys 0.02
If we switch off optimization passes 5 (CFG based) and 6 (DFA based,
only in 7.1), everything is great again in all versions:
$ time -p php -dopcache.enable_cli=1
-dopcache.optimization_level=0x7FFFFFCF hugeclass.php
real 0.13
user 0.10
sys 0.02
For 5.6 and 7.0, pass 6 is not a thing, but in 7.1, we can inspect
passes 5 and 6 separately.
Pass 5 (CFG based) already makes for a drastic performance hit in 7.1:
$ time -p php -dopcache.enable_cli=1
-dopcache.optimization_level=0x7FFFFFDF hugeclass.php
real 0.88
user 0.86
sys 0.01
But pass 6 (DFA based) is the one that causes the biggest slowdown in
7.1:
$ time -p php -dopcache.enable_cli=1
-dopcache.optimization_level=0x7FFFFFEF hugeclass.php
real 3.29
user 3.24
sys 0.04
In all versions, subsequent loads from the cache (such as when running
FPM or the built-in web server) are fast.
Confirmed as bug in both CFG and DFA passes by Nikita:
http://news.php.net/php.internals/98518
Test script:
---------------
https://gist.github.com/dzuelke/fe867f55f09e0bf79ecefcc815b7fe92
--
Edit bug report at https://bugs.php.net/bug.php?id=74250&edit=1
--
Try a snapshot (PHP 5.4): https://bugs.php.net/fix.php?id=74250&r=trysnapshot54
Try a snapshot (PHP 5.5): https://bugs.php.net/fix.php?id=74250&r=trysnapshot55
Try a snapshot (trunk): https://bugs.php.net/fix.php?id=74250&r=trysnapshottrunk
Fixed in SVN: https://bugs.php.net/fix.php?id=74250&r=fixed
Fixed in release: https://bugs.php.net/fix.php?id=74250&r=alreadyfixed
Need backtrace: https://bugs.php.net/fix.php?id=74250&r=needtrace
Need Reproduce Script: https://bugs.php.net/fix.php?id=74250&r=needscript
Try newer version: https://bugs.php.net/fix.php?id=74250&r=oldversion
Not developer issue: https://bugs.php.net/fix.php?id=74250&r=support
Expected behavior: https://bugs.php.net/fix.php?id=74250&r=notwrong
Not enough info: https://bugs.php.net/fix.php?id=74250&r=notenoughinfo
Submitted twice: https://bugs.php.net/fix.php?id=74250&r=submittedtwice
register_globals: https://bugs.php.net/fix.php?id=74250&r=globals
PHP 4 support discontinued: https://bugs.php.net/fix.php?id=74250&r=php4
Daylight Savings: https://bugs.php.net/fix.php?id=74250&r=dst
IIS Stability: https://bugs.php.net/fix.php?id=74250&r=isapi
Install GNU Sed: https://bugs.php.net/fix.php?id=74250&r=gnused
Floating point limitations: https://bugs.php.net/fix.php?id=74250&r=float
No Zend Extensions: https://bugs.php.net/fix.php?id=74250&r=nozend
MySQL Configuration Error: https://bugs.php.net/fix.php?id=74250&r=mysqlcfg