-
Notifications
You must be signed in to change notification settings - Fork 98
Efficiently pack metadata versions in network structs #3196
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
in_response_to, | ||
span_context: None, | ||
/// Returns the version of the metadata for the given kind. | ||
#[must_use] |
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.
Why is this a must_use
?
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.
it's a good habit for functions that have no side effects. If the only value of calling a function is its return value, then you'd want the linter to notify them if they aren't using the return value.
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.
LGTM 👍🏼
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.
Nice changes :-) LGTM. +1 for merging.
Leveraging the fact the Version::INVALID is 0 to pack the metadata versions better in memory. Version needs 4 bytes (u32) while Option<Version> needs 8. `PeerMetadataVersion` now needs 16 bytes instead of 32, same for `Header`. The other change is to let `MetadataVersions` keep track of the actual observed version of the peer as this might come handy for introspection later. This doesn't impact performance as we still only notify if the version is higher than our latest local view. ``` // intentionally empty ```
Leveraging the fact the Version::INVALID is 0 to pack the metadata versions better in memory. Version needs 4 bytes (u32) while Option needs 8.
PeerMetadataVersion
now needs 16 bytes instead of 32, same forHeader
.The other change is to let
MetadataVersions
keep track of the actual observed version of the peer as this might come handy for introspection later. This doesn't impact performance as we still only notify if the version is higher than our latest local view.Stack created with Sapling. Best reviewed with ReviewStack.