Related posts
- Compiling Angie too, and the hardening my compiled PHP was missing
Angie compiled from source served cached pages 4-6 % faster; zlib-ng cut its gzip cost by a fifth. PGO, AutoFDO and a static glibc were measured; and the from-source php-fpm got back the stack protector and RELRO that upstream clang leaves off.
- Three php-fpm builds side by side: Sury, clang + BOLT, and everything from source
My earlier compiled-PHP tests found nothing. Two flaws in my build harness were hiding the gain: GCC was built without its global registers, and BOLT was never tried. With both fixed, a BOLT-optimised php-fpm is 5-10 % faster on logged-in XenForo pages. Building every library from upstream as well added nothing measurable.
- Why my from-source PHP was slower, and the one-line answer: ICU
A from-source php-fpm executed 9 % fewer instructions per page than a clang build using Sury's extensions, yet ran 1-2 % slower. The cause was ICU: the intl extension made the binary 102 MB and multiplied data-TLB misses by 4.5. Without it, the merged build is the fastest: +11 % on logged-in XenForo pages.
The last post compiled Angie and fixed the hardening my compiled PHP was missing. This round added Valkey, a single
--source=switch for all the builds, and a few more questions: could Elasticsearch and MariaDB be compiled too, and is nginx faster than Angie once both are built the same way? Same Xeon E-2236 test host, WordPress, XenForo and Chevereto, rotated rounds, clock pinned.One switch#
--source=all,--source=angie,phpor--source=none, like--others. A fresh install uses the packages; a plain--optimizekeeps whatever builds the server already runs.Valkey was 35 % slower, then it wasn’t#
My first Valkey 9.2 build lost to Ubuntu’s 9.0.6 package by 32-41 % on pipelined requests. Counting instructions per request with
perf stat, which CPU contention cannot skew, made the cause obvious:make CFLAGS="..."CFLAGS="..." makeA variable on make’s command line overrides the assignment in every sub-make. Valkey builds its bundled jemalloc and Lua with their own
-Oflags, and myCFLAGS=replaced them with flags that had no-Oat all, so the allocator ran unoptimised. Passed through the environment instead, the same flags leave the dependencies alone. With BOLT on top, the compiled Valkey beats the package by 3 % on pipelined GET and SET and up to 1.5 % on single requests. Valkey is about 0.3 % of a forum page’s CPU, though, so nobody will see it on a page.The flag that made my stacks executable#
Next, the BOLTed Valkey refused to start. Its systemd unit has
MemoryDenyWriteExecute=yes, and the binary had noGNU_STACKprogram header. I had been running BOLT with-use-gnu-stack, which tells it to reuse that header slot for the new code segment it writes. Without the header, Linux gives the process an executable stack.My compiled php-fpm and Angie had been BOLTed with the same flag for two releases. Their units do not set
MemoryDenyWriteExecute, so they started fine, with executable stacks. Without the flag, BOLT moves the program headers instead and keepsGNU_STACKread-write. Every build now refuses a BOLT output without it, and the existing builds rebuild on the next--optimize.nginx vs Angie, compiled the same way#
Angie 1.12.5 and nginx 1.31.10, same clang flags, OpenSSL, PCRE2, zlib-ng, Brotli and modules, on identical configuration files:
nginx is 0.5-1.5 % ahead on cached pages and level on PHP pages. Compiling matters more than the choice between the two.
What I did not compile#
-fno-pltwith link-time-O3landed inside the noise; a higher inline threshold was 2-4 % slower and 3 MB larger. The shipped build is still 6.5-11.3 % ahead of the package.x-pack-core,x-pack-security,apm, then settings in its keystore and cluster state). Not worth the reindex and the fragility.Smaller things#
auth_basic. A directive it cannot serve, likesub_filter, is commented out with a marker when the build is activated and restored when it is removed.