Posts tagged “Mimalloc”
Pinned: One idempotent script for the whole Ubuntu web stack
Angie, PHP-FPM, MariaDB, Valkey and Elasticsearch from a single Bash entry point: every command, option and safety rule in one place.

Setup script 1.22.5, before and after: XenForo 17-32 % faster on the same box
I benchmarked the whole 1.22.5 release against 1.22.4 the way a server gets it: an --optimize run, a reboot, then load. Cached XenForo pages went from 122k to 161k req/s, uncached pages 17-22 % faster, p99 14-20 % lower, and PHP-FPM uses half the memory. Most of it is the kernel; the rest is a new allocator for PHP, a lower Brotli level and AWS-LC under nginx. The benchmark also caught a bug that would have stopped every updated server from rebuilding PHP.

Moving servers off Sury PHP and Angie packages: five bugs I found first
Before running my setup script's one-time migration on live servers, I rebuilt their package-based setup on a test box and in VMs, for every PHP series from 8.1 to 8.6 and for Ubuntu 24.04. The migration worked on the first host shape I had tested, and broke in five different ways on the others. Fixed, it makes cached pages 13-19 % faster and PHP pages up to 14 % faster.

kTLS with nginx: 44 % less CPU on big files, and a 200 ms stall
Kernel TLS lets nginx encrypt files with sendfile(). On this server it first did not work at all: a 1 MB file never finished, because of one sysctl my own script sets. Fixed, kTLS cut nginx's CPU on large files by 40-44 % but made small responses 38 % slower. It stays off.

nginx with OpenSSL 3.5, OpenSSL 4.1, AWS-LC or BoringSSL
The same nginx 1.31 built against four TLS libraries. AWS-LC and BoringSSL need half of OpenSSL's CPU for an ECDSA handshake, post-quantum key exchange included. Keep-alive and bulk transfers tie. OpenSSL 4.1 beats the 3.5 LTS and stays the default, because the others take features away.

XenForo on PHP 8.1 to 8.6: the same build six times
Six PHP series compiled with the same clang recipe and the same extensions, one XenForo forum with 100,000 posts, plain nginx, PHP-FPM and MariaDB. PHP 8.5 and 8.6 serve uncached pages 8-11 % faster than 8.1. 8.2, 8.3 and 8.4 tie, and 8.6 adds nothing over 8.5 yet.

Dropping the packages: compiled nginx, PHP and Valkey, and what the migration tests broke
My setup script now builds nginx, PHP and Valkey from source and installs none of them from packages. Live servers migrate once, on --optimize. Testing that migration and a PHP downgrade chain found eight bugs, including a build log that grew to 1.7 TB. A day later, 1.22.1 dropped pre-compressed static files.

Compiling Valkey, and the BOLT flag that gave my binaries an executable stack
Valkey from source was 35 % slower until I stopped passing CFLAGS on make's command line. Then its unit refused the BOLTed binary, which exposed an executable stack in my compiled PHP and Angie too. Plus nginx vs Angie, compiled the same way.

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.

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.
