-
-
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
benches: move sender to a spawned task in watch
benchmark
#6034
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.
Interesting observation. Thanks. What do you think we should do about the less-contention change?
After all, there's also a disadvantage to having it, namely that it makes the allocation a lot larger. |
I ran the original benchmark from the thread in #5403 (tijsvd/tokio-watch-benchmark) and the results don't seem to favor new notifier (
old notifier (just
The author of this benchmark mentioned that he used an 8-vcore machine, so I used 8 worker threads as well. I think that if I can't observe any benefit from |
If you think it doesn't make a difference, then go ahead and undo the |
Sorry for the late response. I ran the benchmarks mentioned above on other machines with significantly weaker CPUs and |
Sounds good to me. |
Motivation
The PR #5464 introduced a new bucket notifier to reduce contention in the
watch
channel. That change was motivated by the benchmark added in #5472. However, this benchmark does not present favorable results for the newer notifier if we compare it with the older solution.Results with the new notifier:
contention_resubscribe time: [81.507 ms 82.098 ms 82.740 ms]
Results without it:
contention_resubscribe time: [38.254 ms 38.938 ms 39.618 ms]
This is most likely due to sender task not running on a worker thread.
Solution
Change the existing
watch
channel benchmark by moving the benchmarked loop to a spawned task, which will be executed by one of the worker threads. With this change the results are more comparable:new notifier:
old notifier:
Note that since the addition of the new notifier, some optimizations (#5503) have been made to the underlying
Notify
primitive. Those also reduced lock contention so the new bucket solution no longer presents as significant improvements (or any improvement at all) in this benchmark as it might at the time of its addition. I still think it's worth keeping around as it improves performance with more worker threads. Here are the results using 24 worker threads (all of the above results were obtained using 6):new notifier:
old notifier:
For benchmarking, I used a 12-core x86_64 machine running Linux 6.5.4.