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

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

Open
mxinden opened this issue Dec 12, 2024 · 2 comments
Open

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

mxinden opened this issue Dec 12, 2024 · 2 comments
Labels
good first issue Good for newcomers p3 Backlog

Comments

@mxinden
Copy link
Collaborator

mxinden commented Dec 12, 2024

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.

let mut dgram_data = Encoder::default();
dgram_data.encode_varint(self.session_id.as_u64() / 4);
dgram_data.encode(buf);
conn.send_datagram(dgram_data.into(), id)?;

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

@mxinden mxinden added good first issue Good for newcomers p3 Backlog labels Dec 12, 2024
@mansf-osk
Copy link
Collaborator

I will take a look!

@mansf-osk
Copy link
Collaborator

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.

self.datagrams.push_back(QuicDatagram { data, tracking });

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).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
good first issue Good for newcomers p3 Backlog
Projects
None yet
Development

No branches or pull requests

2 participants