Skip to content

Refactor quic traits Connection and OpenStreams to use self: Pin<&mut Self> instead of &mut self #298

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

Open
Ruben2424 opened this issue Apr 8, 2025 · 0 comments
Labels
A-trait Area: quic trait abstraction C-performance Category: performance. This is making existing behavior go faster. C-refactor Category: refactor. This would improve the clarity of internal code.

Comments

@Ruben2424
Copy link
Contributor

The current quic traits have &mut self in the function signature. For example:

    fn poll_accept_recv(
        &mut self,
        cx: &mut task::Context<'_>,
    ) -> Poll<Result<Self::RecvStream, ConnectionErrorIncoming>>;

In the original proposal some of the trait methods had self: Pin<&mut Self> instead.
https://github.com/hyperium/h3/blob/master/docs/PROPOSAL.md#connections

It would take a large refactor to chance it now, but i think it is possible for the Connection and OpenStreams trait.

This would allow quic implementations like h3-quinn to not require Boxing the streams.

h3/h3-quinn/src/lib.rs

Lines 45 to 48 in bf078de

incoming_bi: BoxStreamSync<'static, <AcceptBi<'static> as Future>::Output>,
opening_bi: Option<BoxStreamSync<'static, <OpenBi<'static> as Future>::Output>>,
incoming_uni: BoxStreamSync<'static, <AcceptUni<'static> as Future>::Output>,
opening_uni: Option<BoxStreamSync<'static, <OpenUni<'static> as Future>::Output>>,

What do you think, is it worth the time?

With a little digging and found this comment.
#3 (comment)

This comment refes to the RecvStream trait.
The problem mentioned in the comment can be worked around for Connection and OpenStreams which only have two methods not needing Pin , which is close and opener.
Either by defining a new separate trait for close and opener or by maintaining a separate cloneable instance of OpenStreams which is not pinned.

@Ruben2424 Ruben2424 added A-trait Area: quic trait abstraction C-performance Category: performance. This is making existing behavior go faster. C-refactor Category: refactor. This would improve the clarity of internal code. labels Apr 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-trait Area: quic trait abstraction C-performance Category: performance. This is making existing behavior go faster. C-refactor Category: refactor. This would improve the clarity of internal code.
Projects
None yet
Development

No branches or pull requests

1 participant