|
php.net | support | documentation | report a bug | advanced search | search howto | statistics | random bug | login |
[2019-12-29 15:23 UTC] benjamin dot morel at gmail dot com
Description:
------------
I'm attempting to preload ~3000 PHP classes in my web app, with a simple preloading script that basically calls opcache_compile_file() on each file contained in Composer's autoload_classmap.php, minus a few namespaces that contain many files that are rarely used. I'm including the preload.php script in the "Test script" section here.
When I activate preloading in opcache.ini:
opcache.preload=/path/to/preload.php
I get 503 errors from Apache, that suddenly can't connect to php-fpm.
A quick look at /var/log/php-fpm/error.log shows the following errors:
[29-Dec-2019 16:12:56] NOTICE: [pool nicebooks] child 23191 started
[29-Dec-2019 16:12:56] WARNING: [pool www] child 23182 exited on signal 11 (SIGSEGV) after 0.002705 seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool www] child 23192 started
[29-Dec-2019 16:12:56] WARNING: [pool www] child 23183 exited on signal 11 (SIGSEGV) after 0.002702 seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool www] child 23193 started
[29-Dec-2019 16:12:56] WARNING: [pool nicebooks] child 23184 exited on signal 11 (SIGSEGV) after 0.002710 seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool nicebooks] child 23194 started
[29-Dec-2019 16:12:56] WARNING: [pool nicebooks] child 23185 exited on signal 11 (SIGSEGV) after 0.002746 seconds from start
[29-Dec-2019 16:12:56] NOTICE: [pool nicebooks] child 23196 started
[29-Dec-2019 16:12:56] WARNING: [pool www] child 23186 exited on signal 11 (SIGSEGV) after 0.002733 seconds from start
Looks like all php-fpm workers segfault right after starting with preloading enabled.
I'm not sure how I can provide a minimum reproducible example without giving out the whole project source.
Test script:
---------------
<?php
// preload.php
$blacklist = [
'Amazon\\ProductAdvertisingAPI\\',
'Aws\\',
'Brick\\Schema\\',
'DTS\\eBaySDK\\',
'Google\\AdsApi\\',
'phpDocumentor\\'
];
$files = require __DIR__ . '/vendor/composer/autoload_classmap.php';
$filtered = [];
foreach ($files as $class => $file) {
foreach ($blacklist as $prefix) {
if (strpos($class, $prefix) === 0) {
continue 2;
}
}
$filtered[$class] = $file;
}
foreach (array_unique($filtered) as $file) {
opcache_compile_file($file);
}
PatchesPull RequestsHistoryAllCommentsChangesGit/SVN commits
|
|||||||||||||||||||||||||||||||||||||
Copyright © 2001-2025 The PHP GroupAll rights reserved. |
Last updated: Fri Oct 24 01:00:02 2025 UTC |
Same issue with PHP 7.4.2-RC1, released a few hours ago. Still SIGSEGV. SIGSEGV only happens when I configure preloading in /etc/php.d/opcache.ini, though: opcache.preload=/home/username/example.com/current/preload.php opcache.preload_user=username Everything seems to work fine if I configure it in php-fpm.d instead: php_admin_value[opcache.preload] = /home/username/example.com/current/preload.php php_admin_value[opcache.preload_user] = username But even though I can see the configuration being applied (in the Configuration tab of https://github.com/rlerdorf/opcache-status), I don't measure any performance improvement with preloading enabled. I'm surprised as this is not in line with the benchmarks I had run a year ago: https://github.com/composer/composer/issues/7777#issuecomment-440268416 As far as I can tell, it looks like preloading is not in effect when configured this way.