Re: [RFC] Single binary for CLI and FPM

From: Date: Wed, 25 Nov 2026 23:09:09 +0000
Subject: Re: [RFC] Single binary for CLI and FPM
References: 1 2  Groups: php.internals 
Request: Send a blank email to internals+get-133224@lists.php.net to get a copy of this message
> Perhaps there's another alternative: libzend.so. [...] In any case, the > performance penalty would be something to measure, but I would prefer > this solution if it's viable, personally. I measured it. The closest thing that builds today is --enable-embed=shared: it produces a libphp.so that contains the engine, the extensions and the CLI (since #21385). I linked php and php-fpm as two tiny executables against it and compared that with the regular php executable. Cold starts on AWS Lambda: same gain as the single binary. That's good. However runtime performance is not as good. On x86-64, with all variants running interleaved on the same host (142 rounds, median difference with the regular executable): libphp.so libphp.so + -Bsymbolic bench.php +5.4% +0.2% bench.php (opcache) +3.6% +0.2% micro_bench.php +7.7% +0.5% micro_bench (opcache) +3.9% +0.6% php-parser (opcache) +1.8% +0.0% The first column is already built with -fno-semantic-interposition and -Wl,-Bsymbolic-functions (the Lambda hosts were all Intel Xeon). According to Claude, the cause is EG() and CG(): in a PIE executable, gcc accesses executor_globals directly, in a shared library through the GOT (936 places in zend_execute.c alone). -Bsymbolic-functions does not cover data. -Bsymbolic does: the linker then turns the GOT loads back into direct addressing, and the cost is mostly gone. On arm64 (measured locally) there is no difference with those flags (±0.5%), because gcc goes through the GOT for extern data even in a PIE executable there. Without them it costs about 2%. So in theory it could work, but -Bsymbolic is required (i.e. needs larger changes for distribution), and that could be a problem with programs that embed PHP like FrankenPHP AFAICT. In the end I don't think this approach is better than a single binary, correct me if I'm wrong. Matthieu

« previous php.internals (#133224) next »