quinn-rs / quinn

Async-friendly QUIC implementation in Rust
Apache License 2.0
3.57k stars 363 forks source link

refactor(endpoint): use array::from_fn instead of unsafe MaybeUninit #1806

Closed mxinden closed 2 months ago

mxinden commented 2 months ago

With Rust 1.63.0 one can initialize a std::array via std::array::from_fn.

https://doc.rust-lang.org/std/array/fn.from_fn.html

Thus there is no need to start with an uninitialized array via MaybeUninit, initialize it and then use unsafe to assume_init. Instead one can initialize the array with the concrete elements right away.


Meta: quinn-udp has been very helpful in https://github.com/mozilla/neqo/pull/1741. Thanks!

djc commented 2 months ago

Meta: quinn-udp has been very helpful in mozilla/neqo#1741. Thanks!

What happened to the plan to use quinn-udp directly for neqo?

mxinden commented 2 months ago

Meta: quinn-udp has been very helpful in mozilla/neqo#1741. Thanks!

What happened to the plan to use quinn-udp directly for neqo?

For others, some context: https://github.com/quinn-rs/quinn/issues/1749.

For now, I am refactoring neqo-client and neqo-server, two wrappers around the Neqo state machine, to use quinn-udp and thereby be able to test ECN (https://github.com/mozilla/neqo/pull/1678/) and multi-packet I/O (https://github.com/mozilla/neqo/issues/1693). Note neither neqo-client nor neqo-server are used in Firefox.

Whether long term quinn-udp will be used in Firefox, or whether this work will only inform a decision on future next steps for Firefox' UDP I/O layer, is beyond my powers, but up to the folks at Mozilla. (Note I am not affiliated with Mozilla. Just an external contributor.)

djc commented 2 months ago

For now, I am refactoring neqo-client and neqo-server, two wrappers around the Neqo state machine, to use quinn-udp and thereby be able to test ECN (mozilla/neqo#1678) and multi-packet I/O (mozilla/neqo#1693). Note neither neqo-client nor neqo-server are used in Firefox.

Whether long term quinn-udp will be used in Firefox, or whether this work will only inform a decision on future next steps for Firefox' UDP I/O layer, is beyond my powers, but up to the folks at Mozilla. (Note I am not affiliated with Mozilla. Just an external contributor.)

I'm still curious -- does Firefox still use neqo, if it doesn't use neqo-client or neqo-server? If you're not at Mozilla, what is your goal in contributing to Neqo?

mxinden commented 2 months ago

does Firefox still use neqo

Yes https://searchfox.org/mozilla-central/source/netwerk/socket/neqo_glue/Cargo.toml#12-15

if it doesn't use neqo-client or neqo-server

Sorry for the confusion. Firefox uses neqo-http3, neqo-transport, neqo-common and neqo-qpack. These are the equivalent to quinn-proto. For I/O, Firefox uses https://github.com/nss-dev/nspr (simplified) the equivalent to quinn-udp.

In order to test the above neqo-* crates only without having to build all of Firefox, one can instead use the small non-production binary crates neqo-client and neqo-server. Instead of NSPR, neqo-client and neqo-server use quinn-udp (since https://github.com/mozilla/neqo/pull/1604).

Does that help @djc?

If you're not at Mozilla, what is your goal in contributing to Neqo?

I have left rust-libp2p in December https://max-inden.de/post/2024-02-29-stepping-down/. Assuming that is where you know me from. While looking for a new job, Neqo is a great way to spend my free time.

djc commented 2 months ago

I have left rust-libp2p in December https://max-inden.de/post/2024-02-29-stepping-down/. Assuming that is where you know me from. While looking for a new job, Neqo is a great way to spend my free time.

Yeah, that is where I knew you from -- was just wondering if someone was paying you to work on Neqo. Enjoy the time off!