-
Notifications
You must be signed in to change notification settings - Fork 1k
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
fix(swarm): eliminating protocol cloning when nothing is happening #5026
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.
Great stuff! I have some questions. Also, did you manage to benchmark this somehow?
I ll try few benchmark strategies and will see. This should improve, so long as protocols don't change with each poll. |
since we always insert all of the protocols to the hashset on each poll, it hinders the performance |
I am now using hashmap with booleans to compute the diff, so no need to collect the protocols.
|
finally this is results of benchmark on old code:
|
@thomaseizinger I am curios what you think about the way I benchmark it |
I realized am testing with very short protocol names so here is a little change
|
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.
Thank you for the updates! I've left some comments :)
I am liking the direction this is going in and looking forward to merge the performance improvements!
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.
Thank you for the updates! I've left some more comments with questions and suggestions :)
@thomaseizinger, hey, did I miss something that still needs to be done? |
Sorry for the delay. I am on low availability until mid-Jan. Will give this a review after! :) |
that was the problem, scarry |
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.
This looks great! Thank you very much.
We have some automation that will use the text in ## Description
in your PR as the commit message for the squash-merged commit.
Could you include some benchmark results in there? Just the criterion run is good with current master
as the baseline?
added |
@jxs All yours from here. |
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.
Hi, and Sorry for the delay in the review. Looking forward to land this! Left just some minor comments.
Thanks
This pull request has merge conflicts. Could you please resolve them @jakubDoka? 🙏 |
Co-authored-by: João Oliveira <[email protected]>
Co-authored-by: João Oliveira <[email protected]>
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.
Sorry for the delay. LGTM! Thanks @jakubDoka!
Approvals have been dismissed because the PR was updated after the send-it
label was applied.
Code keeps the API while eliminating repetitive protocol cloning when protocols did not change, If protocol changes occur, only then the protocols are cloned to a reused buffer from which they are borrowed for iteration. Following are benchmark results: |behaviour count|iterations|protocols|timings|change*| |-|-|-|-|-| |1|1000|10|27.798 µs 28.134 µs 28.493 µs|-15.771% -14.523% -13.269%| |1|1000|100|55.171 µs 55.578 µs 56.009 µs|-51.831% -50.162% -48.437%| |1|1000|1000|289.24 µs 290.99 µs 293.00 µs|-61.748% -60.895% -60.054%| |5|1000|2|34.000 µs 34.216 µs 34.457 µs|-18.538% -16.231% -14.011%| |5|1000|20|70.962 µs 71.428 µs 72.005 µs|-40.501% -38.944% -37.309%| |5|1000|200|426.17 µs 433.27 µs 442.60 µs|-44.824% -42.663% -40.262%| |10|1000|1|42.993 µs 44.382 µs 45.655 µs|-18.839% -16.292% -13.584%| |10|1000|10|94.022 µs 96.787 µs 99.321 µs|-25.469% -23.572% -21.562%| |10|1000|100|543.13 µs 554.91 µs 569.06 µs|-43.781% -42.189% -40.568%| |20|500|1|63.150 µs 64.846 µs 66.860 µs|-9.5693% -6.1722% -2.6400%| |20|500|10|212.21 µs 217.48 µs 222.64 µs|-16.525% -14.234% -11.925%| |20|500|100|1.6651 ms 1.7083 ms 1.7490 ms|-27.704% -25.683% -23.618%| change*: 3da7d91 is the baseline Pull-Request: libp2p#5026.
Description
Code keeps the API while eliminating repetitive protocol cloning when protocols did not change, If protocol changes occur, only then the protocols are cloned to a reused buffer from which they are borrowed for iteration. Following are benchmark results:
change*: 3da7d91 is the baseline
Notes & open questions
Change checklist