Repository navigation
feat: frankenphp_get_vars() and WorkerHandle::setVars() - #2635
Open
nicolas-grekas wants to merge 12 commits into
Open
nicolas-grekas wants to merge 12 commits into
nicolas-grekas wants to merge 12 commits into
Conversation
nicolas-grekas
force-pushed
the
bgworker-vars
branch
2 times, most recently
from
September 6, 2026 20:38
8803c92 to
bddf0bc
Compare
4 tasks
nicolas-grekas
force-pushed
the
bgworker-vars
branch
from
September 7, 2026 06:07
bddf0bc to
6970bf8
Compare
This was referenced Sep 7, 2026
nicolas-grekas
force-pushed
the
bgworker-vars
branch
6 times, most recently
from
September 10, 2026 20:57
c728208 to
2ece59c
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
11 times, most recently
from
September 18, 2026 16:54
20120eb to
97ddc03
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
3 times, most recently
from
September 19, 2026 19:18
8d1ddcd to
4e44158
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
7 times, most recently
from
September 24, 2026 08:11
d374bef to
869596a
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
from
September 30, 2026 16:03
869596a to
139ec91
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
from
October 27, 2026 09:36
8ed945e to
ef96031
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
from
October 27, 2026 14:29
ef96031 to
5c49b00
Compare
Names were scoped per server so a script could address a background worker by name within its php_server. The namespaces of php#2635 and php#2636 do that now and no PHP API takes a worker name, so naming goes back to what main does: Caddy makes generated names unique, and the server label and the ServerMetrics interface are gone. The extension worker fixes leave too, main has the same bugs and they get a pull request of their own.
Since php#2660 worker threads come on top of num_threads and max_threads bounds the whole process. Background threads were the one exception, which took a reservation through calculateMaxThreads(), initPHPThreads() and the automatic max_threads. They now follow the same rule as HTTP workers.
HTTP workers wait for their ready point without a bound too, on builds without Zend max execution timers, so the bound belongs with both kinds of worker. Background workers keep the bound of max_execution_time where those timers exist, and the warning logged after 10 seconds elsewhere.
Init() waits for a background worker to reach its ready point, its first WorkerHandle::tick(). On a build with Zend max execution timers, max_execution_time ends a bootstrap that overstays; without them FrankenPHP disables that limit, so a script that parks before ticking, or one whose wake-up at start is lost, keeps the server start waiting for ever with a warning as the only trace. boot_timeout bounds that wait, 30 seconds by default, the same figure PHP's own max_execution_time uses for the bootstrap it does bound. The worker is then drained and stopped through the boot-failure path it already has, and Init() returns the name of the worker that never ticked. Zero waits for ever.
nicolas-grekas
force-pushed
the
bgworker-vars
branch
2 times, most recently
from
October 27, 2026 16:21
aac930d to
445f8bc
Compare
nicolas-grekas
force-pushed
the
bgworker-vars
branch
from
October 27, 2026 17:12
445f8bc to
4e772ee
Compare
The timeout reported through a blocking send, so a second timeout could wait for room in startupFailChan for good, Init() with it. It now reports like the handlers do and moves the thread to ShuttingDown, so no run starts after the one that overstayed, whether the timeout lands in a run or between two failed boots. The 30s default now only applies where Zend max execution timers are missing, as the docs said: elsewhere max_execution_time bounds the bootstrap, and a set_time_limit() raising it is no longer cut short. Comments and docs that drifted are updated, and the thread budget and the Caddy directive get the tests they lacked.
frankenphp_get_vars() copied the snapshot inside a Go callback with its slot read-locked, so a bailout during the copy, past memory_limit or in an autoloader an enum triggers, left the lock held: the publisher and the next readers waited for good, Shutdown() with them. Snapshots are now counted references, the copy runs in C with no lock held and lets go of the snapshot on every path. The class name of an enum went to the autoloaders as the persistent string of the snapshot, so one keeping it pointed into memory the next publication freed, and readers raced on its refcount. The lookup now uses a request copy. A worker waiting on another one at boot now gives up when the start fails, so an HTTP worker reading vars in its bootstrap no longer keeps Init() waiting on a publisher that never comes up, and a Caddy JSON config no longer drops vars declared on an HTTP worker.
nicolas-grekas
force-pushed
the
bgworker-vars
branch
from
October 27, 2026 18:15
4e772ee to
1d8594a
Compare
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Stacked on #2617: review the commits on top of it.
Shared state for background workers, the vars half of #2287. A worker declares the namespaces it publishes, and readers name the namespace, never the worker:
php_serverfirst, then the global workers, andValidate()refuses conflicts; a worker publishing vars runs a single thread.tick(), which the server start waits for, so requests never wait for a snapshot.Left out on purpose: the per-request cache and the unchanged-data skip of #2287, until there are numbers for them.