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: add zero-copy connection support #3642

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

hf
Copy link
Contributor

@hf hf commented Dec 24, 2022

Adds the ability to use zero-copy connections with QUIC.

Internally, the package already uses a pull based model for reading packets. It first gets a byte slice from a buffer pool, then it reads into this slice using the ReadFrom method. This read then returns a receivedPacket structure which is processed accordingly.

This PR allows for the creation of receivedPacket structures without using copy semantics originating from ReadFrom and WriteTo methods.

It accomplishes this by allowing the use of a custom buffer pool per connection. QUIC can request a new buffer to be allocated, typically for writing. Each byte slice is accompanied by an int tag which uniquely identifies that buffer. When QUIC is done processing the slice, it will release the buffer from the pool. Custom buffer pools can use the tag to identify the state of such a buffer.

Similarly, byte slices originating from a zero-copy ReadPacket() function should also originate from the same buffer pool and be tracked with tags.

Thus, by using the byte slice tag you can coordinate zero-copy or asynchronous sends and receives. For example, you can use io_uring queues to send or read buffers; or eBPF urings for reading only, etc.

(This is a WIP PR and I would love a discussion over it.)

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.

None yet

1 participant