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

feat: don't allocate in UDP recv path #2184

Merged
merged 4 commits into from
Oct 23, 2024
Merged

feat: don't allocate in UDP recv path #2184

merged 4 commits into from
Oct 23, 2024

Commits on Oct 23, 2024

  1. feat(common): make Datagram generic over payload type

    Previously the payload type of `Datagram` was `Vec<u8>`, thus the `Datagram`
    always owned the UDP datagram payload.
    
    This change enables `Datagram` to represent both (a) an owned payload allocation
    (i.e. `Vec<u8>`), but also represent (b) a view into an existing payload (e.g. a
    long lived receive buffer via `&[u8]`).
    
    The default payload type stays `Vec<u8>`, thus not breaking existing usage of
    `Datagram`.
    mxinden committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    dc31bbc View commit details
    Browse the repository at this point in the history
  2. feat(transport): accept borrowed instead of owned input datagram

    Previously `process_input` (and the like) took a `Datagram<Vec<u8>>` as input.
    In other words, it required allocating each UDP datagram payload in a dedicated
    `Vec<u8>` before passing it to `process_input`.
    
    With this patch, `process_input` accepts a `Datagram<&[u8]>`. In other words, it
    accepts a `Datagram` with a borrowed view into an existing buffer (`&[u8]`),
    e.g. a long lived receive buffer.
    mxinden committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    a1c43f7 View commit details
    Browse the repository at this point in the history
  3. feat(udp): return borrowed Datagram on receive

    Previously `recv_inner` would return `Datagram<Vec<u8>>`. In other words, it
    would allocate a new `Vec<u8>` for each UDP datagram payload.
    
    Now `recv_inner` reads into a provided buffer and returns `Datagram<&[u8]>`,
    i.e. it returns a view into the provided buffer without allocating.
    mxinden committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    df66716 View commit details
    Browse the repository at this point in the history
  4. feat(bin): don't allocate in UDP recv path (#2189)

    Pass a long lived receive buffer to `neqo_udp::recv_inner`, receiving an
    iterator of `Datagram<&[u8]>`s pointing into that buffer, thus no longer
    allocating in UDP receive path.
    mxinden committed Oct 23, 2024
    Configuration menu
    Copy the full SHA
    2b322d7 View commit details
    Browse the repository at this point in the history