Don't use SEND_ONCE mach rights for async, use a queue limit of 1 #102
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.
SEND_ONCE allocates a mach port with a SEND right exactly once and deallocates it automatically once the message is read. This is totally wasteful because we have a perfectly good mach port already... This commit adds the send right to our existing mach port and reuses it for each send. This avoids any port allocations.
We additionally call mach_port_set_attributes to set the queue limit for the mach port to 1. We don't need to allocate and queue a bunch of messages when all we need is 1 to wake up. This should speed up notifications AND waiting because draining will only ever drain 1.
Related bug for those with access: ghostty-org/ghostty#1836