-
Notifications
You must be signed in to change notification settings - Fork 8
[optimization] move Sender/Receiver data #6
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
Conversation
|
@cod10129 Thanks for your contribution. Did you run benchmarks, I mean |
|
@mahdi-shojaee I considered it yesterday when I made the PR, but realized that my results wouldn't be comparable to your results so I wrote doing benchmarking off. I just finished the results now and got great results, gaining up to 20% on certain tests. I observed that the tests with the biggest improvements were the ones with their execution time dominated by spawning senders/receivers, as I would have expected. |
|
Great! I'll run the benchmarks either today or tomorrow. |
|
If you're going to do that you would have to run the benchmarks on a local clone of my fork and then merge that or just merge this PR to |
|
Sorry for the delay. I ran the benchmarks, and some improvements are noticeable. Thanks for your efforts! However, could you please update your commits as follows:
|
This commit optimizes performance in the Sender and Receiver types, as their two AtomicUsizes are now behind one Arc instead of two different ones.
This does NOT include the tests/flume_* files, like you asked.
|
I learned some git commands from StackOverflow and got the changes fixed. |
|
Ok, Thanks for your PR. I will merge both commits and in the next future will update the Clippy commit. For now I will not update the benchmarks, as I'm currently working on a fix that is expected to significantly reduce performance. |
Your URLO post has attracted a contributor!
The implementation of
Receiverlooks like this:That's three different
Arcs! I optimized the code to haveReceiver<T>look like this:(The
Arcaroundshared_stateis still necessary because theSharedStatelives outside of the group of allReceivers on a channel. Therecv_countandnext_idfields are one per channel.)This change is also mirrored on
Sender/SenderInner.I also took the liberty to fix various clippy warnings in the tests (try
cargo clippy --all-targets).Unresolved Questions
Should the structs have an
Arc<Inner>holding theArc<Mutex<SharedState>>, or should they have both theArc<Inner>and shared state next to each other?Basically, should
Receiverlook like this instead of the change I made?