-
-
Notifications
You must be signed in to change notification settings - Fork 2.5k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
process: avoid redundant effort to reap orphan processes #3743
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This seems good to me.
How does this PR affect #3521? |
The mutex in |
* Child processes are akin to global variables within the parent process. Reaping orphaned child processes can be done by any thread (so long as someone does it), but repeated efforts from multiple threads to reap the same process do not add any additional benefit * Previously, each Runtime would register its own SIGCHLD listener and check it for updates during every tick. If a signal was received, then it will attempt to reap the orphan queue. * Signals are also "global resources" meaning that when one signal comes in, all listeners within that process are woken up. This means that if an application has multiple runtimes, each of them will attempt to drain the entire orphan queue any time a SIGCHLD is received (the first one to try will reap whichever orphans have exited, and the other will perform redundant effort). * Now we register a single SIGCHLD listener for the entire global queue itself, which allows us to "dedup" signal notifications even if multiple runtimes tick at the same time and attempt to drive the orphan queue (one will grab a lock and win the race, and everyone else will move on). * Moreover, the single, global SIGCHLD listener will be registered lazily (instead of eagerly on the runtime initialization). This means that applications which do not use child processes will not "pollute" the signal handler space, even if the feature is enabled at compile time
Co-authored-by: Alice Ryhl <alice@ryhl.io>
4859b2f
to
2c5c624
Compare
Did that force push have any changes, or was it just a merge of master? (Please try to avoid force pushes — I can't tell what has changed and usually need to review the entire thing again) |
@Darksonn sorry I rebased on master because there was an unrelated failure (BSD test failed on some warning for an unused return value from sleep) |
No worries, although it's usually enough to merge in master. |
process. Reaping orphaned child processes can be done by any thread
(so long as someone does it), but repeated efforts from multiple
threads to reap the same process do not add any additional benefit
check it for updates during every tick. If a signal was received, then
it will attempt to reap the orphan queue.
in, all listeners within that process are woken up. This means that if
an application has multiple runtimes, each of them will attempt to
drain the entire orphan queue any time a SIGCHLD is received (the
first one to try will reap whichever orphans have exited, and the
other will perform redundant effort).
itself, which allows us to "dedup" signal notifications even if
multiple runtimes tick at the same time and attempt to drive the
orphan queue (one will grab a lock and win the race, and everyone else
will move on).
lazily (instead of eagerly on the runtime initialization). This means
that applications which do not use child processes will not "pollute"
the signal handler space, even if the feature is enabled at compile
time
Refs #3520