posix_spawn: Unconditionally default all signals (except HUP)#10869
Merged
Conversation
We don't really care if the process has a custom handler installed, we
can just set it to default.
The one we check is SIGHUP, which may be given to us via `nohup`.
This saves ~30 syscalls *per process* we spawn, so:
```fish
for f in (seq 1000)
command true
end
```
has ~30000 fewer rt_sigaction calls. These take up about ~30% of the
total time spent in syscalls according to strace.
We could also compute this set once at startup and then reuse it.
ridiculousfish
approved these changes
Nov 30, 2024
Member
ridiculousfish
left a comment
There was a problem hiding this comment.
Great find! I can't think of any reason to not do this.
Contributor
yeah we can cache these indefinitely, other shells do that too |
faho
added a commit
that referenced
this pull request
Dec 4, 2024
Really the only thing we're looking for here is if we're started with HUP ignored or not. Saves a syscall per external process. Continuation of #10869
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 subscribe to this conversation on GitHub.
Already have an account?
Sign in.
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.
As I understand it, we want all signals for processes we spawn (except for HUP, because of nohup) to have the default signal handlers.
So I don't know why we need to check what action a specific signal currently has, we can just default it anyway.
This saves ~30 syscalls per process we spawn, so:
has ~30000 fewer rt_sigaction calls. These take up about ~30% of the total time spent in syscalls according to strace.
We could also compute this set once at startup and then reuse it.