Skip to content

refactor(connlib): only buffer 1 unsent packet if socket is busy#6563

Merged
thomaseizinger merged 4 commits intomainfrom
refactor/remove-buffering
Sep 4, 2024
Merged

refactor(connlib): only buffer 1 unsent packet if socket is busy#6563
thomaseizinger merged 4 commits intomainfrom
refactor/remove-buffering

Conversation

@thomaseizinger
Copy link
Copy Markdown
Member

Currently, we buffer UDP packets whenever the socket is busy and try to flush them out at a later point. This requires allocations and is tricky to get right.

In order to solve both of these problems, we refactor snownet to return us an EncryptedPacket instead of a Transmit. An EncryptedPacket is an indirection-abstraction that can be turned into a Transmit given an EncryptBuffer. This combination of types allows us to hold on to the EncryptedPacket (which does not contain any references itself) in the io component whilst we are waiting for the socket to be ready to send again.

This means we will immediately suspend the event loop in case the socket is no longer ready for sending and resend the datagram in the EncryptBuffer once we get re-polled.

@vercel
Copy link
Copy Markdown

vercel bot commented Sep 3, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
firezone ✅ Ready (Inspect) Visit Preview 💬 Add feedback Sep 3, 2024 4:17am

Copy link
Copy Markdown
Contributor

@conectado conectado left a comment

Choose a reason for hiding this comment

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

LGTM!

@thomaseizinger thomaseizinger added this pull request to the merge queue Sep 4, 2024
Merged via the queue into main with commit e3688a4 Sep 4, 2024
@thomaseizinger thomaseizinger deleted the refactor/remove-buffering branch September 4, 2024 17:17
jamilbk pushed a commit that referenced this pull request Sep 4, 2024
Currently, we buffer UDP packets whenever the socket is busy and try to
flush them out at a later point. This requires allocations and is tricky
to get right.

In order to solve both of these problems, we refactor `snownet` to
return us an `EncryptedPacket` instead of a `Transmit`. An
`EncryptedPacket` is an indirection-abstraction that can be turned into
a `Transmit` given an `EncryptBuffer`. This combination of types allows
us to hold on to the `EncryptedPacket` (which does not contain any
references itself) in the `io` component whilst we are waiting for the
socket to be ready to send again.

This means we will immediately suspend the event loop in case the socket
is no longer ready for sending and resend the datagram in the
`EncryptBuffer` once we get re-polled.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants