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

feat(iroh-net)!: Improve initial connection latency #2234

Merged
merged 30 commits into from
May 8, 2024

Conversation

flub
Copy link
Contributor

@flub flub commented Apr 25, 2024

Description

When the magic socket changes the underlying path the congestion controller has all the wrong ideas about the latency. This results in widely varying latencies and only slowly settling of them. This change resets the values of the congestion controller whenever the magic socket path changes. The result is a much faster stable connection.

Renames the Pong::src field to ping_observed_addr to try and make this field a bit more intuitive to read. This helps especially around logging pongs and the UDP address of the pong sender next to each other.

The mesh_stacks function in the tests has the relay server removed. The point of the function is to hook up the magic endpoints using direct addresses, so the relay is redundant. Furthermore the way the server was set up in the tests made it not functional, so it never did anything. So things are simplified without it.

Breaking Changes

  • MagicEndpoint::accept now returns magic_endpoint::Accept rather than Quinn's Accept type.
  • magic_endpoint::Connecting replaces quinn::Connecting. This is the type returned by .awaiting the Accept future.
  • magic_endpoint::accept_conn and magic_endpoint::get_alpn have been removed. You now accept the connection by directly awaiting the futures returned. To retrieve the ALPN use the new Connecting::alpn method.

Notes & open questions

To review, start at the new rtt_actor.rs, that's the important bit. Then look at MagicEndpoint how it adds it to .connect() (simple) and .accept() (complex). The latter requires copying a bunch of Quinn structs into magic_endpoint. This also simplifies how the interact with the alpn a little. Everything else is how making the rest of iroh adapt to those changes.

Change checklist

  • Self-review.
  • Documentation updates if relevant.
  • Tests if relevant.
  • All breaking changes documented.

TODO

  • [ ] Use stream-util instead of futures-concurrency

@flub flub added feat New feature or request c-iroh labels Apr 25, 2024
@dignifiedquire dignifiedquire added this to the v0.16.0 milestone Apr 29, 2024
@flub flub marked this pull request as ready for review May 6, 2024 16:15
@flub flub changed the title feat(iroh-net): Improve initial connection latency feat(iroh-net)!: Improve initial connection latency May 6, 2024
@flub flub requested a review from dignifiedquire May 6, 2024 16:16
@dignifiedquire
Copy link
Contributor

looks like iroh-sync still pulls in quinn

@flub flub requested a review from dignifiedquire May 8, 2024 13:29
@flub
Copy link
Contributor Author

flub commented May 8, 2024

PTAL, I believe this is ready now.

@dignifiedquire
Copy link
Contributor

ci sad

flub added 2 commits May 8, 2024 17:16
it used to require quinn for this
@dignifiedquire dignifiedquire added this pull request to the merge queue May 8, 2024
Merged via the queue into main with commit ec48b0d May 8, 2024
21 of 22 checks passed
@flub flub deleted the flub/messing-around-with-rtt branch May 10, 2024 07:57
matheus23 pushed a commit that referenced this pull request Nov 14, 2024
## Description

When the magic socket changes the underlying path the congestion
controller has all the wrong ideas about the latency. This results in
widely varying latencies and only slowly settling of them. This change
resets the values of the congestion controller whenever the magic socket
path changes. The result is a much faster stable connection.

Renames the Pong::src field to ping_observed_addr to try and make this
field a bit more intuitive to read. This helps especially around logging
pongs and the UDP address of the pong sender next to each other.

The mesh_stacks function in the tests has the relay server removed. The
point of the function is to hook up the magic endpoints using direct
addresses, so the relay is redundant. Furthermore the way the server was
set up in the tests made it not functional, so it never did anything. So
things are simplified without it.

## Breaking Changes

- `MagicEndpoint::accept` now returns `magic_endpoint::Accept` rather
than Quinn's `Accept` type.
- `magic_endpoint::Connecting` replaces `quinn::Connecting`. This is the
type returned by `.await`ing the `Accept` future.
- `magic_endpoint::accept_conn` and `magic_endpoint::get_alpn` have been
removed. You now accept the connection by directly awaiting the futures
returned. To retrieve the ALPN use the new `Connecting::alpn` method.

## Notes & open questions

To review, start at the new `rtt_actor.rs`, that's the important bit.
Then look at `MagicEndpoint` how it adds it to `.connect()` (simple) and
`.accept()` (complex). The latter requires copying a bunch of Quinn
structs into magic_endpoint. This also simplifies how the interact with
the alpn a little. Everything else is how making the rest of iroh adapt
to those changes.

## Change checklist

- [x] Self-review.
- [x] Documentation updates if relevant.
- [x] Tests if relevant.
- [x] All breaking changes documented.

## TODO

- ~~[ ] Use stream-util instead of futures-concurrency~~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
c-iroh feat New feature or request
Projects
Archived in project
Development

Successfully merging this pull request may close these issues.

2 participants