Repository navigation
feat: SentTaskHandle and ReceivedTaskHandle - #2636
Open
nicolas-grekas wants to merge 27 commits into
Open
nicolas-grekas wants to merge 27 commits into
nicolas-grekas wants to merge 27 commits into
Conversation
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
2 times, most recently
from
September 7, 2026 07:56
c0eccbe to
6e571ec
Compare
This was referenced Sep 7, 2026
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
September 7, 2026 09:32
6e571ec to
23d3094
Compare
Contributor
Author
|
Pushed |
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
5 times, most recently
from
September 9, 2026 17:53
4c5af56 to
2b77a5b
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
5 times, most recently
from
September 14, 2026 06:16
e0be4ac to
fd177fc
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
11 times, most recently
from
September 18, 2026 16:58
a8f1a7f to
a9d72df
Compare
…shutdown The docs also tell to keep the scripts of background workers out of the document root.
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
November 7, 2026 17:40
73dad02 to
95f0805
Compare
3 of 18 tasks
FRANKENPHP_WORKER_BACKGROUND is now a flag set to 1, like FRANKENPHP_WORKER, since the name comes from the handle. The threads endpoint names background threads after their worker rather than their script, which several workers may share.
zend_enum_get_case_cstr() only asserts that the case exists, so a snapshot or payload written against another version of an enum dereferenced NULL in release builds, or took a plain constant of that name for an object. The case is now looked up in the constants table and checked, and a mismatch throws the existing LogicException.
… handle A persistent copy is malloc memory outside the memory_limit of the request making it, and every occurrence of a shared value gets its own copy: a hundred references to one megabyte took a hundred megabytes. The check now counts the bytes of the copy and refuses one past memory_limit, which also bounds the walk of a value shared many times over, and says which rule a value breaks. frankenphp_get_vars() created a cgo.Handle and copied the namespace on every read, about 250ns and three allocations, and throughput fell as readers were added (global handle map, GC). The snapshots being copied now sit on a stack of the thread instead, which also pairs the nested read an autoloader can make. Conflicting declarations name both workers, a worker reading its own vars before its first tick is told so, and an unknown namespace says where it was looked for.
…() may have no caller
…eException for the moment
A pickup crossing an abort no longer leaves a second wake-up for the sender's next wait.
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
November 8, 2026 19:59
94dcca4 to
e892ab7
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 and #2635: review the commits on top of them.
Tasks for background workers, the task half of #2319. A worker declares the namespaces it receives, and a sender names the namespace:
SentTaskHandlewaits for a thread to pick the task up and throws on timeout, so a busy worker pushes back instead of queueing without bounds.WorkerHandle, so the loop of feat: background workers andFrankenPHP\WorkerHandle#2617 doesn't change.Io\Poll\Handlewith agetStream(), like the worker's.abandon(), or dropping the handle, gives up on the task, which the worker learns fromupdate()returningfalse; a worker letting go of a task withoutcomplete()makes the sender's nextread()throw.The metrics follow:
frankenphp_busy_workersandfrankenphp_worker_queue_depthcount tasks, plusfrankenphp_worker_task_count{outcome}andfrankenphp_worker_task_timefor aMetricsimplementation that also implementsTaskMetrics.Left out compared to #2319: a queue ahead of pickup, and cancelling a task before it.