Dispatcher: Reduce operations by moving things into a single Arc#3318
Merged
Dispatcher: Reduce operations by moving things into a single Arc#3318
Conversation
Member
Author
|
Latest numbers on this using the benchmark from #3320: |
e1be510 to
a08de40
Compare
Member
Author
|
A final run of the benchmark: Note that the improvements vary. |
Member
Author
|
oops, forgot to put it up for review |
Member
Author
|
ok, now with some reconfigurations of my machines to make behavior more stable, I get reliable numbers, improvements across the board. |
chutten
approved these changes
Nov 21, 2025
Contributor
chutten
left a comment
There was a problem hiding this comment.
Probably doesn't need a CHANGELOG, but maybe we put one in just so we can see it in release notes?
a08de40 to
88c96f2
Compare
Before dropping a `DispatchGuard` required invoking drop on 2 `Arc`s (reducing their reference count) and 3 `Sender`. That happens for every single `launch` on the global dispatcher (because that clones a new guard). That's a bit overkill. `Sender` is already `Sync` (when its `T` is `Send`), that means it's enough if we keep one of them around (behind the outer `Arc`, our `T` is the launched function with an explicit `Send` bound). Before this the drop of `DispatchGuard` shows up in profiles for a synthetic benchmark (7.5% for that drop, with 3.4% attributed to dropping `Sender`). With this patch that overhead seems to be gone.
88c96f2 to
8984c2e
Compare
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.
Before dropping a
DispatchGuardrequired invoking drop on 2Arcs (reducing their reference count) and 3Sender.That happens for every single
launchon the global dispatcher (because that clones a new guard).That's a bit overkill.
Senderis alreadySync(when itsTisSend), that means it's enough if we keep one of them around (behind the outerArc, ourTis the launched function with an explicitSendbound). Before this the drop ofDispatchGuardshows up in profiles for a synthetic benchmark (7.5% for that drop, with 3.4% attributed to droppingSender).With this patch that overhead seems to be gone.
I'm working on reliable numbers to back this up, but I wanted to already push it up and get CI going.