Uh oh!
There was an error while loading. Please reload this page.
refactor: decouple worker threads from non-worker threads - #1137
Conversation
# Conflicts: # frankenphp.c # frankenphp.go # php_thread.go # worker.go
ghost
commented
Nov 4, 2024
Hmm that segfault is interesting, It's probably not fully safe to execute a PHP script while calling |
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AlliBalliBaba
commented
Dec 8, 2024
I also want to try if it's safe to boot a thread at runtime (might be necessary for #1216). BOoting led to segfaults when I tested it previously, but it might be safe after this opcache fix. |
withinboredom
commented
Dec 8, 2024
Organizations can now apply for the arm beta from GitHub (at least, it is offered in my org). Just a matter of time until we can run these on arm machines instead of emulating them. But, LGTM. |
dunglas
commented
Dec 8, 2024
@withinboredom do you have the link for the wait list? |
In the organization action runner settings, there was just a button to enable them. I don't see it on any of the free orgs I have admin access to, just the paid one. |
dunglas
left a comment
There was a problem hiding this comment.
Sounds very very good! I left some minor comments, and there are some TODOs to fix, then we'll be ready to merge.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
AlliBalliBaba
commented
Dec 10, 2024
Something else I've been wondering: When using the watcher, should an initial worker startup failure panic also be prevented? |
dunglas
commented
Dec 10, 2024
Indeed, good idea. When watchers are enabled, we should never panic IMHO. |
dunglas
commented
Dec 17, 2024
Thank you @AlliBalliBaba! |
This PR refactors how threads are started and is meant as a step towards scaling threads at runtime.
How worker threads are currently started:
Currently, worker threads are started from regular threads via sending a special request
to ServeHTTP. The disadvantage here is that between sending the special worker request
and receiving it, we are losing control over which thread becomes a worker thread.
Worker threads and regular threads are inevitable coupled to each other.
How worker threads are started with this PR:
This PR decouples worker threads from regular threads and makes the
php_threadstructa wrapper around the thread's lifetime.
A 'PHP thread' is currently just a
pthreadwith its ownTSRMstorage (this doesn'tnecessarily have to be tied to a real thread in the future as discussed in #1090).
The thread starts, does some work in a loop and then stops. This PR makes it possible
to configure these 3 lifetime hooks from the go side via the
php_threadstruct:This allows re-using the same mechanism for regular threads as well as worker threads.
It also makes it easier to create other potential types of threads in the future
(like 'scheduled workers' or 'task workers').
Additionally, it now would also be possible to grab an 'idle thread', exchange it's hooks and
turn it into a different type of thread at runtime without stopping the underlying thread.
(This PR doesn't go that far though)