Skip to content

perf: reuse zend max execution timers between requests - #25673

Open
henderkes wants to merge 6 commits into
php:masterfrom
henderkes:perf/zts-timer-reuse
Open

henderkes wants to merge 6 commits into
php:masterfrom
henderkes:perf/zts-timer-reuse

Conversation

@henderkes

@henderkes henderkes commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

logic on master: each request creates a timer, sets time limit, deletes the timer
logic here: each thread creates a timer, each request sets time limit, then after the request sets time limit to zero. timer is reused by the next request.

this skips noticeable overhead, especially in threaded scenarios (first measurement in frankenphp ~4% for hello world), but also in NTS (if max execution timers are enabled)

FreeBSD excluded for now because of https://github.com/freebsd/freebsd-src/blob/main/sys/sys/timers.h#L65

cc @dunglas

remember it once for all threads, so a host signal still reaches its handler if it lands on a different PHP thread
@henderkes

henderkes commented Nov 24, 2026 •

Copy link
Copy Markdown
Contributor Author

4 core workload:

Stack Workload Base req/s PR req/s Paired change [95% interval]
NTS FPM + nginx Hello 40,860 41,292 +1.06% [+0.86, +1.25]
NTS FPM + nginx Symfony 1,495 1,502 +0.49% [+0.23, +0.74]
ZTS FPM + nginx Hello 39,863 40,317 +1.14% [+0.91, +1.37]
ZTS FPM + nginx Symfony 1,451 1,458 +0.50% [+0.26, +0.75]
Classic FrankenPHP Hello 40,607 41,601 +2.45% [+1.61, +3.29]
Classic FrankenPHP Symfony 1,329 1,340 +0.85% [+0.61, +1.10]

Benchmarked and table generated by gpt, but I got very similar numbers in manual wrk runs, so I think it's more or less correct in the realm of local hardware not being the most stable.

WIll measure gains with higher concurrency later Edit: will not, big.LITTLE architecture on my hardware seems to lead to very inconsistent results.

cc @Girgias

@henderkes
henderkes marked this pull request as ready for review November 24, 2026 04:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant