-
Notifications
You must be signed in to change notification settings - Fork 74
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
Add two caches to the peers
state machine
#2898
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.
Automatically approving tomaka's pull requests. This auto-approval will be removed once more maintainers are active.
Thanks to the debug_asserts!, I'm quite confident that the logic is correct. Every single time we make sure that the value is in there if it should be in there, or not in there if it shouldn't be in there. All the debug_asserts are run pretty frequently. |
twiggy diff reportDifference in .wasm size before and after this pull request.
|
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.
👍
The
Peers
state machine has two functions:unfulfilled_desired_outbound_substreams
andfulfilled_undesired_outbound_substreams
. They return a list of peer-substreams tuples.These two functions are called very frequently (every time something happens on the networking), they are
O(n)
(they iterate over every single substream of every single peer), and most of the time they return nothing.This PR adds two new fields to the
peers
state machine with the same names as these functions.The functions now simply return the content of the field, and the field is updated pro-actively whenever something else changes.