Follow-ups for the background worker stack
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 11.3k
- Forks
- 488
- Avg merge
- 4d 10h
- Merged PRs (30d)
- 11
Description
Things left to do or decide after #2617 and its stack, so they don't get lost.
-
Validate a configuration before stopping the running one:
Start()callsInit()after the old app stopped, so any declaration error leaves the site down while Caddy rolls the configuration back. A side-effect-free preflight shared withInit(), called fromValidate(). https://github.com/php/frankenphp/pull/2617#discussion_r3987787721 -
Synchronize the startup-failure boundary: publishing
ShuttingDownwakes the startup waiter before the thread finished its exit path, and a shutdown request is not distinguished from a thread that exited. Both worker handlers share that path. https://github.com/php/frankenphp/pull/2617#discussion_r3987787784 -
Pull the rest of the common bookkeeping into
workerLifecycleonce that boundary has one shape. https://github.com/php/frankenphp/pull/2617#discussion_r3987787771 -
num_regular_threads/max_regular_threads, so nobody computes the thread budget by hand. https://github.com/php/frankenphp/pull/2617#discussion_r3866053582 -
Implement
Io\Poll\HandleonFrankenPHP\WorkerHandleand the task handles, done in #2617 and #2636 on top of the 8.6 job of #2658 -
Drop the per-task
php_streamfrom the common path of #2636, now that a handle's lifetime is exactly the task's: hold the task state in the object, settle infree_obj, and build the stream lazily ingetStream(), so a script that never multiplexes allocates no stream and no resource per task. Then recycle the handles themselves, through a per-thread free list. Channels stay eventfds on Linux; on macOS look for the equivalent, a kqueue descriptor triggered withEVFILT_USERis pollable and needs no pair, a pipe is the usual fallback (libuv's async handles), and Windows keeps the socket pair forphp_select().
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with #2617 and #2636, then read the linked discussions and the worker entry points named here: Start(), Init(), Validate(), workerLifecycle, and the worker/task handle paths. Choose one unchecked follow-up; it is done when that specific configuration, lifecycle, thread-budget, handle, or platform-channel behavior is implemented and the corresponding checklist item can be verified.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go, php
- Domain
- backend
- Issue type
- Refactor
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Active
- Clarity
- Needs clarification
- Newbie friendliness
- 25/100