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(transport): don't pre-allocate mtu on max_datagram_size #2086

Merged
merged 2 commits into from
Sep 25, 2024

Commits on Sep 3, 2024

  1. perf(transport): don't pre-allocate mtu on max_datagram_size

    The `neqo_transport::Connection::max_datagram_size` creates an `Encoder`, writes
    a packet header and a packet number and determines how many bytes of the mtu are left.
    
    https://github.com/mozilla/neqo/blob/28f60bd0ba3209ecba4102eec123859a3a8afd45/neqo-transport/src/connection/mod.rs#L3408-L3427
    
    The `Encoder` only has to hold the packet header and the packet number. Yet it
    is initialized with `Encoder::with_capacity(mtu)`.
    
    https://github.com/mozilla/neqo/blob/28f60bd0ba3209ecba4102eec123859a3a8afd45/neqo-transport/src/connection/mod.rs#L3408
    
    Note that `PacketBuilder::short` and `PacketBuilder::long` read the
    `Encoder::capacity` through `PacketBuilder::infer_limit`. But
    `PacketBuilder::infer_limit` falls back to `2048` if the capacity is below `64`,
    which will be the case when using `Encoder::default()` instead of
    `Encoder::with_capacity(mtu)`. `2048` should be plenty enough for the packet
    header and the packet number.
    
    https://github.com/mozilla/neqo/blob/28f60bd0ba3209ecba4102eec123859a3a8afd45/neqo-transport/src/packet/mod.rs#L152-L180
    
    https://github.com/mozilla/neqo/blob/28f60bd0ba3209ecba4102eec123859a3a8afd45/neqo-transport/src/packet/mod.rs#L188-L225
    
    https://github.com/mozilla/neqo/blob/28f60bd0ba3209ecba4102eec123859a3a8afd45/neqo-transport/src/packet/mod.rs#L135-L141
    
    This commit prevents the wasted allocation by using `Encoder::default()` instead
    of `Encoder::with_capacity(mtu)`.
    mxinden committed Sep 3, 2024
    Configuration menu
    Copy the full SHA
    dbfc372 View commit details
    Browse the repository at this point in the history

Commits on Sep 25, 2024

  1. Configuration menu
    Copy the full SHA
    c3e5999 View commit details
    Browse the repository at this point in the history