neqo icon indicating copy to clipboard operation
neqo copied to clipboard

perf(http3): don't re-allocate outbound datagram to prefix with varint

Open mxinden opened this issue 1 year ago • 2 comments

When sending an HTTP3 datagram, we prefix it with the session id. In order to do so, we write the session ID into a new Encoder and then copy the entire datagram over into that Encoder.

https://github.com/mozilla/neqo/blob/3001a3a56f2274eaafaa956fb394f0817f526ae7/neqo-http3/src/features/extended_connect/webtransport_session.rs#L415-L418

We might be able to do better, e.g. passing session ID and datagram down separately.

mxinden avatar Dec 12 '24 15:12 mxinden

I will take a look!

omansfeld avatar Jan 14 '25 11:01 omansfeld

This is not easily possible I think. We need ownership of the data in QuicDatagrams::add_datagram when we push it into the queue as a new QuicDatagram so we need to reallocate at some point anyways, might as well do it here while we prefix the session ID.

https://github.com/mozilla/neqo/blob/3001a3a56f2274eaafaa956fb394f0817f526ae7/neqo-transport/src/quic_datagrams.rs#L170

Maybe we could do something with lifetimes there, but I'm not experienced enough with Rust to assess if that would be at all feasible (and going by Max's "if you're using lifetimes you're probably doing something wrong" advice, probably not).

omansfeld avatar Jan 21 '25 13:01 omansfeld