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
Vectored I/O with datagrams #1724
Comments
I'm not sure allocating a separate |
Sorry, I updated the description with some more information and less of a proposal. The issue is that I need to allocate a copy of each datagram since there's no way to prepend/append otherwise. I don't have any performance numbers but this would undoubtedly be an issue at high throughput. |
I think this is already supported with the current API? A
That is, it should be possible to allocate a single |
Not quite the same issue. The key thing is that I'm writing a library, so I don't actually create the datagram payload. The application creates the datagram payload and my library prefixes it with the WebTransport header before sending. You're right that the application could encode the A similar issue is fragmentation. Let's say I have a 1MB video Meanwhile, the streams API lets you avoid this. You can do two separate writes: one for the header and one for the |
Yeah, that generally makes sense. I'm curious how much the extra API complexity would actually buy us, though. Streams can have much larger individual writes, though I guess in either case you might be sending up to at most the link capacity, so maybe it's not so different... I'm open to having this. |
Yeah I don't think there's any urgency for this API. I'm not using datagrams and actively advocate against them. But this would be a blocker for using datagrams at scale. Allocating on the heap for every packet gets expensive. I'm just going to leave a comment in my library and link to this issue. |
I'm adding datagram support to
webtransport-quinn
. WebTransport uses asession_id
VarInt in front of each datagram to disambiguate sessions.My plan goal is to mirror the Quinn API but have the
session_id
prefix transparent to the application, something like:Unfortunately, with the current Quinn API it's impossible to avoid allocating a copy of every datagram.
Bytes
must be contiguous in memory.Bytes
must be on the heap, so I can't make a copy on the stack.Bytes
references are held, so I can't reuse the sameBytesMut
to avoid allocating each time.The core issue is that there's no vectored IO for datagrams. This wouldn't be a problem with the stream API because you can call
write
multiple times, but it's a problem for the datagram API because you need the entire payload up front.The text was updated successfully, but these errors were encountered: