Skip to content
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

refactor(iroh): Newtype the packet sent over relay servers #3030

Merged
merged 2 commits into from
Dec 12, 2024

Conversation

flub
Copy link
Contributor

@flub flub commented Dec 11, 2024

Description

There is a difference between the datagrams that the MagicSock sends and the packets that contain datagrams that gets sent to relay servers. But this was all just Bytes.

This newtypes the packets explicitly and makes it a sibling of the existing RelayRecvDatagram. Now the PacketizeIter at least does not both consume and produce the same type, because they're not the same things.

Breaking Changes

Notes & open questions

This clones the RelayUrl (usually) twice per packet sent now, instead of (usually) once. That's the only thing I don't like about this really.

I still wonder whether RelayUrl should not be some sort of interned and cloned thing.

Watch out, the base of this PR is flub/active-relay-again.

Change checklist

  • Self-review.
  • Documentation updates following the style guide, if relevant.
  • Tests if relevant.
  • All breaking changes documented.

@flub flub requested a review from a team December 11, 2024 17:49
@flub flub added this to the v0.30.0 milestone Dec 11, 2024
@flub flub self-assigned this Dec 11, 2024
Copy link

github-actions bot commented Dec 11, 2024

Documentation for this PR has been generated and is available at: https://n0-computer.github.io/iroh/pr/3030/docs/iroh/

Last updated: 2024-12-12T14:39:17Z

Copy link

github-actions bot commented Dec 11, 2024

Netsim report & logs for this PR have been generated and is available at: LOGS
This report will remain available for 3 days.

Last updated for commit: 32cd0dd

Copy link
Contributor

@matheus23 matheus23 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This looks like a good change, but I need someone to explain to me why this is a RelaySendPacket, not a RelaySendDatagram and why the Recv one is the other way around.

@flub
Copy link
Contributor Author

flub commented Dec 12, 2024

This looks like a good change, but I need someone to explain to me why this is a RelaySendPacket, not a RelaySendDatagram and why the Recv one is the other way around.

The explanation is in the PacketizeIter: it prefixes every datagram with a u16be length and potentially concatenates several datagrams together.

Whether that is a good idea I'm going to leave alone. I... don't think it is?? It basically only happens when Quinn manages to send a GSO datagram (and I'm not sure if that is really hooked up properly currently so that it would, I think it is though). But the point of GSO datagrams is to have less work but we now do another copy of every packet because we need to prefix it with 2 bytes. So we really are hurting because of this instead of improving. The relay protocol should probably have a separate frame/packet type for GSO datagrams with the stride length encoded in it.

Actually... let me write this as an issue...

(I'll also improve the docs in this PR a little)

@flub flub force-pushed the flub/active-relay-again branch from e29b41b to 2ec4263 Compare December 12, 2024 13:43
Base automatically changed from flub/active-relay-again to main December 12, 2024 14:04
@flub flub force-pushed the flub/more-newtypes-fewer-bytes branch from c5a2f86 to 90f09f7 Compare December 12, 2024 14:11
flub added 2 commits December 12, 2024 15:33
There is a difference between the datagrams that the MagicSock sends
and the packets that contain datagrams that gets sent to relay
servers.  But this was all just Bytes.

This newtypes the packets explicitly and makes it a sibling of the
existing RelayRecvDatagram.  Now the PacketizeIter at least does not
both consume and produce the same type, because they're not the same
things.
@flub flub force-pushed the flub/more-newtypes-fewer-bytes branch from 90f09f7 to 7399e75 Compare December 12, 2024 14:36
@flub flub enabled auto-merge December 12, 2024 14:38
@flub flub added this pull request to the merge queue Dec 12, 2024
Merged via the queue into main with commit e7503c0 Dec 12, 2024
26 checks passed
@flub flub deleted the flub/more-newtypes-fewer-bytes branch December 12, 2024 14:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
Status: ✅ Done
Development

Successfully merging this pull request may close these issues.

2 participants