-
Notifications
You must be signed in to change notification settings - Fork 292
refactor(iroh): Re-batch datagrams inside RelayTransport
instead of the ActiveRelayActor
#3421
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
Merged
Merged
Changes from all commits
Commits
Show all changes
6 commits
Select commit
Hold shift + click to select a range
0748160
refactor(iroh): Re-batch datagrams inside `RelayTransport::poll_recv`
matheus23 e0cbc1d
Rework pending item logic
matheus23 7f9e6c1
Fix comment
matheus23 5d37be3
Fix the logic
matheus23 1af03c2
Fix typo in comment
matheus23 5182926
Fix: Uphold invariant if we're removing the second-last segment(s) of…
matheus23 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
One problem I have with this behaviour is that a segment_size of something with a empty contents (or even with just one datagram) is supposed to be illegal according to the docs of the struct.
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.
Maybe this could be simplified by always having a
segement_size
? It's only the serialisation that needs to be linux-compatible. Likewise we can declare that an emptyDatagrams
is allows and provide anis_empty
method.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.
I think the only invariant that's invalidated here is that
self.contents
can be empty after this call.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.
Actually that's not a claimed invariant.
Datagrams
doesn't have any restrictions oncontents
. We only check that on receive, but that's basically it.Can you tell me which invariant from the
Datagams
documentation is actually invalidated?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.
Line 141-143 in this file in this PR:
We can change this to
segment_size: NonZeroU16
and add to the docs of thecontents
field that it might be empty, just should always be a multiple ofsegment_size
if non-empty. Then this becomes a little more consistent?Apologies for my vague reviews, I should clearly give more context up front!
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.
In your initial review comment you write:
I don't see where it says that?
This is a different invariant:
The current code still respects that.
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.
I think after you call
Datagrams::take_segments
this guarantee is not upheld? You can end up with a single item butsegment_size
being stillSome
or it can be empty, in which casesegment_size
can not be right.Though I appreciate that the way you use it does at least solve the 2nd issue.
Anyway, I don't feel like my comments here are being helpful, or maybe I'm even misunderstanding things. This conversation isn't really improving the quality of the code. Apologies to hold things up.
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.
Ugh, I'm sorry. You're right that I missed a case where the invariant is broken in
self
.I kept double-checking the return value and what's stored in
self
after the early-return and missed what's stored inself
after the late return.Sorry this took so long :X