Related posts
- clang, PHP 8.4 and the missing zlib: the last round of compiled PHP
The final round of the compiled-PHP question: CentminMod's function alignment on its own, a clang build and PHP 8.4, with every module compiled from source. clang is the only build with a repeatable edge (+3 % on XenForo), 8.4 is slower than 8.5, and my earlier source builds were missing zlib.
- Everything on: LTO, PGO and -march=native made PHP 8.5 slower
A follow-up to the four-build PHP test: turn on every CentminMod compiler option, add LTO and two-stage PGO trained on real XenForo traffic, and compile every module from source. The result is 5 to 10 % slower than the distribution package, not faster.
- PHP-FPM, FrankenPHP, RoadRunner or Swoole? The PHP layer decides less than you think
Eleven ways to execute PHP, one application-shaped workload, then the real WordPress, XenForo and Chevereto pages. Worker runtimes are 1.4-1.6x faster, but the applications cannot use them without a port; PHP-FPM stays the default.
Every PHP tuning guide eventually says the same thing: compile PHP yourself, with
-O3 -march=native, and build only the extensions you use. It sounds free. My stack is PHP-bound — 92 % of a logged-in XenForo thread page is PHP-FPM CPU — so if any of that were true it would be the largest remaining win on the server.It is not true here, and the reason is more interesting than the result: with the tracing JIT on, the hot code is generated at run time and never passes through the C compiler at all.
Four ways to install the same PHP#
The test host is the one I use for these audits: a Xeon E-2236 (6 cores / 12 threads, 62 GB, NVMe RAID0), Ubuntu 26.04, Angie, MariaDB, Valkey, and the same three applications as every cycle — WordPress 7.1.4, XenForo 2.3.13 and Chevereto 4.5.9-pro — with 100 loopback connections through TLS.
-O2, generic, hardening, no LTO-O2, generic, hardening-O2 -march=x86-64-O3 -m64 -march=nativeThe last arm is the interesting one. CentminMod’s installer sets
MARCH_TARGETNATIVE=yand leaves LTO and PGO off by default, which resolves to-O3 -m64 -march=<cpu> -pipe; on this Coffee Lake Xeon that isskylake. The binary is visibly different: 26,148 AVX2 instructions inphp-fpmagainst 171 in the distribution builds.The source arms use only what XenForo needs: mysqli, gd, curl, mbstring, xml, zip, gmp, OPcache. One wrinkle: PECL redis 6.2.0 does not compile on PHP 8.5 (
php_smart_string.hwas removed) and PECL imagick 3.8.0 predates it, so redis, igbinary and imagick come from the distribution packages on every arm. That is not a compromise for this test — it means the extension code is identical and only the PHP binary changes.All four arms read the same managed
php.iniand pool: 12 static workers, 512 MB OPcache, tracing JIT with a 64 MB buffer, huge code pages, and an OPcache script table sized for the real file count (130,987, thank you Chevereto’s vendor directory). The clock was pinned at 3.6 GHz because this host’s turbo is power-limited and PHP CPU per request follows the clock 1:1 — a lesson from the last cycle.The result: nothing#
Three rounds, arms rotated forward and backward inside every round, medians in requests per second with the spread in parentheses:
WordPress is flat. XenForo spans −3.8 % to +1.6 % with spreads that overlap the baseline. The only number that looks like a difference is the generic build on Chevereto’s uncached home, and that tier is not PHP-bound at all (1.35 cores busy), so it is an outlier rather than a build effect. Nothing clears the ~3 % bar I use for shipping a change.
A CLI probe made the picture sharper. I wrote a small script with three sections — C builtins (json, preg, string functions, hash, sort), object work, and a userland loop — and ran each arm 15 times without FPM, so there is no scheduler noise:
-O3 -march=nativeis 1.9 % slower than Sury’s plain-O2on the C-builtin section, and the generic source build is 5.5 % slower. The loop section is identical to the microsecond for all four builds.Why the compiler cannot help#
Two things happen when
opcache.jit=tracingis on:A faster C compiler cannot speed up a workload whose hot path is generated code plus MariaDB I/O. You can see the same effect in the first table: the tier that is most PHP-bound (XenForo member thread) is also the one where all four arms are within 3 % of each other, because all four are running the same JIT-emitted code.
What about the Ubuntu packages?#
Ubuntu 26.04’s archive has PHP 8.5.4 with every extension these applications need, and it is exactly as fast as Sury within the noise. I still did not add a
repo=switch to the installer. Two reasons:PHP 8.6, one more time#
I also re-ran the version round trip, since “try the newest that works” is part of every cycle.
--upgrade-php=8.6took 1:23 and carried 14 extensions with none skipped; going back to 8.5 took 1:12.php -lThe two XenForo vendor files (
braintree/Digest.php,laminas-mail/Transport/Null.php) fail the linter on 8.5 as well; there they only break the payment and mail code paths. On 8.6, XenForo’s debug mode turns the deprecations into a 500 on every page, which is enough to keep the forum on 8.5.Zero-error, as usual#
Fresh install in 3:24 with 0 warnings; 1,496 unit checks, 227 dry runs, 67/67 security probes, 86/86 guest-cache cookie cases, functional suite 0 unexpected on 8.5 and on 8.6; two
--optimizeruns with 0 of 3,285 recorded facts different. The host went back to its pristine 696-package manifest, 0 changed files under/etc, mitigations back on. One byte-level detail: the audit’s/etc/hostsline had been appended to a file without a trailing newline, so removing it withsedleft one; truncating that byte restored the baseline digest.What I would tell the next person#
-march=nativeproduced 26,000 AVX2 instructions and zero requests per second.tests/bench-php-matrix/in ubuntu-setup-script, so when PHP 8.7 or a new JIT arrives the question can be answered again in an afternoon instead of an argument.