Repository navigation
feat: SentTaskHandle and ReceivedTaskHandle - #2636
Open
nicolas-grekas wants to merge 3 commits into
Open
nicolas-grekas wants to merge 3 commits into
nicolas-grekas wants to merge 3 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
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
6 times, most recently
from
September 24, 2026 08:14
8925005 to
014aeff
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
September 30, 2026 16:06
014aeff to
9ad72ef
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
October 18, 2026 14:37
9ad72ef to
26399e0
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
8 times, most recently
from
October 31, 2026 06:35
61d9559 to
aab4dff
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
2 times, most recently
from
November 7, 2026 17:40
73dad02 to
95f0805
Compare
3 of 19 tasks
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
November 8, 2026 19:59
94dcca4 to
e892ab7
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
2 times, most recently
from
November 12, 2026 07:50
c34c01b to
14c5dd5
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
November 12, 2026 10:13
14c5dd5 to
6754db5
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
November 12, 2026 14:56
6754db5 to
b76182f
Compare
nicolas-grekas
force-pushed
the
bgworker-tasks
branch
from
November 12, 2026 17:18
b76182f to
e1a2103
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 last commit.
Tasks for background workers, the task half of #2319. A worker declares the namespaces it receives, and a sender names the namespace:
SentTaskHandlequeues the task and returns.$pickupTimeoutruns from the construction: once it passes, the task leaves the queue andread()throws.tick()when it was given a timeout, or on itsWorkerHandlefor a loop waiting there, so the loops of feat: background workers andFrankenPHP\WorkerHandle#2617 don't change.receive()only dequeues.Io\Poll\Handlewith agetStream(), like the worker's.abandon(), or dropping the handle, gives up on the task: it leaves the queue if no thread took it yet, and the worker learns it fromupdate()returningfalseotherwise. On the worker's side,abort(), or dropping the handle withoutcomplete(), makes the sender's nextread()throw.tick()with a timeout,read()and the waits on handles: the constructor,update()andcomplete()return at once, so both sides fit in an event loop and neither can hold the other. The price: FrankenPHP doesn't push back, the queue and the unread updates grow with what the scripts do.stream_select()or a poll context: an eventfd on Linux, a socket pair elsewhere, closed with the task. On a GitHub runner with 4 vCPUs, a task goes round in 5.5 µs without a syscall, and 4 senders on 4 threads pass 110k tasks/s.The metrics follow:
frankenphp_busy_workersandfrankenphp_worker_queue_depthcount tasks, plusfrankenphp_worker_task_count{outcome}andfrankenphp_worker_task_timefor aMetricsimplementation that also implementsTaskMetrics.