Related posts
- Is a compiled PHP faster? Four builds, one Xeon, and a JIT that makes the question moot
Sury packages, Ubuntu's archive, and PHP built from source with -O3 -march=native and only the modules XenForo needs. On a PHP-bound forum the difference was inside the noise, and the reason is the tracing JIT.
- 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.
- Who compresses a logged-in XenForo page? 12 % of PHP, one fastcgi_param, and a clock that lied
Profiling the member pages of a XenForo forum showed zlib eating 12 % of PHP-FPM CPU: XenForo gzips its own pages at level 9 inside the worker. Moving that to Angie gave +5 % on the forum index and +9 % on thread pages. Along the way, a CPU turbo budget faked a 27 % speed-up, and three other ideas did not survive measurement.
The last two posts asked whether a compiled PHP beats the distribution package. First with
-O3 -march=native, then with LTO and PGO switched on. The answer both times was no. A few CentminMod levers were still unmeasured, so this round covers them: function alignment on its own, clang instead of GCC, and PHP 8.4 against 8.5. Every module is compiled from source this time, igbinary included.Short version: clang is the only build that ever beat the package, by about 3 % on XenForo member pages and nothing elsewhere. PHP 8.4 is slower than 8.5. My earlier source builds were missing zlib. The zlib gap biased the earlier comparisons in favour of the source builds, so their conclusions still stand, but you should know about it.
The arms#
-O2, generic-O3 -m64 -march=native -mtune=native -falign-functions=32 -fno-semantic-interposition-falign-functions=32-falign-functions=32is CentminMod’sGCC_FALIGN_FUNCTION=y, and clang is itsCLANG_PHP=y. None of the arms use LTO, which the last post measured as neutral.All modules from source: igbinary 3.2.16 would not build against 8.5 last time. 3.2.17RC1 does, so every arm has igbinary, redis 6.3.0 and imagick 3.8.1 built against its own tree, and no downgrade was needed for it. I measured 8.4 anyway, because I had never compared the two versions on this stack.
A confession first: the source builds had no zlib#
The first run of this matrix gave a “cached” WordPress page at 6,000 requests per second instead of 98,000 whenever a source build was serving. That number is impossible for a cache hit, and it led to the real problem. My source build script never passed
--with-zlib.This matters because the stack has PHP gzip WordPress and Chevereto pages itself (
zlib.output_compression). The guest cache then stores the compressed page, and a hit costs Angie almost nothing. Without zlib, PHP sent an uncompressed page, the cache’s encoding guard refused to store it, and every “hit” went back to PHP.On the uncached tiers the same gap meant less work for PHP, because Angie did the compression on other cores. So in the two previous posts, the WordPress and Chevereto rows of the source builds had a head start. They still didn’t win, so those verdicts hold. XenForo was never affected, because Angie hands XenForo an empty
Accept-Encodingand compresses member pages itself.Every build in this post has
--with-zlib --with-sodium. Before measuring, I checked that a guest page is stored and served from cache under a source build exactly as under the package:[gzip] MISS, then[gzip] HIT.Method#
The same rig as before: a Xeon E-2236 (6 cores, 12 threads) running WordPress, XenForo (200 threads, 2,600 posts) and Chevereto behind Angie, with the clock pinned at 3.6 GHz. The CPU is power-limited, and an unpinned clock fakes differences. Loopback
wrkruns 100 connections for 10 seconds per tier. There are 3 rounds, with the arms rotated forward and then backward, and the cache is emptied before each arm. I report medians and the min–max spread; anything under ~3 % or inside the spread is noise.The numbers#
Median req/s, delta against the package:
clang’s XenForo gain showed up in all three matrices I ran (+2.9 %, +3.3 %, +3.1 % on the home page, and +3.4 % and +3.1 % on the thread in two of them). Its spreads don’t overlap the package’s. It is the first source build in three posts that beat the package anywhere.
A CPU-only probe (15 runs per build, no web server, tracing JIT on) shows the same pattern:
PHP 8.4 is 21 % slower on object and method work, which is exactly what a framework like XenForo spends its time on.
Verdict#
-O3 -march=nativeloses 1–5 %, and function alignment isn’t the reason: the build without it is no better.This is the last round of this question unless the compilers or the JIT change. With the tracing JIT, the hot PHP code is generated at run time, so the C compiler only reaches the interpreter’s helpers.
What else changed this cycle#
A four-reviewer audit of both repositories, with every finding checked by an adversarial reviewer, kept 9 of 16 findings. The ones worth knowing about:
proxy_cachegate in the tree carries the rule..sql.zip,.sql.xz,.sql.zstand friends) are now denied at any depth, not only.sqland.sql.gz.kill -TERMin the middle of a real upgrade. That test found a second bug: the rollback “succeeded”, but every site answered 502. The reinstalled package had already started PHP-FPM on its stock socket, andsystemctl enable --nowdoesn’t restart a unit that is already running. The rollback now restarts PHP-FPM and checks that the right socket is listening.None of these changes moved a cached tier outside its spread in an A/B against the previous configuration.