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(udp): use sendmmsg and recvmmsg #1741

Closed
wants to merge 19 commits into from
Closed

Commits on Mar 21, 2024

  1. feat(udp): use recvmmsg

    Read up to `BATCH_SIZE = 32` with single `recvmmsg` syscall.
    
    Previously `neqo_bin::udp::Socket::recv` would use `recvmmsg`, but provide a
    single buffer to write into only, effectively using `recvmsg` instead of
    `recvmmsg`.
    
    With this commit `Socket::recv` provides `BATCH_SIZE` number of buffers on each
    `recvmmsg` syscall, thus reading more than one datagram at a time if available.
    mxinden committed Mar 21, 2024
    Configuration menu
    Copy the full SHA
    cfcea21 View commit details
    Browse the repository at this point in the history

Commits on Apr 3, 2024

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

    mxinden committed Apr 3, 2024
    Configuration menu
    Copy the full SHA
    1a813e4 View commit details
    Browse the repository at this point in the history

Commits on Apr 4, 2024

  1. Minimal sendmmsg impl

    mxinden committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    b6cd481 View commit details
    Browse the repository at this point in the history
  2. Use BATCH_SIZE

    mxinden committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    22da54f View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    3f9eb9c View commit details
    Browse the repository at this point in the history
  4. Support multiple sockets

    mxinden committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    dfd0226 View commit details
    Browse the repository at this point in the history
  5. Configuration menu
    Copy the full SHA
    a262e37 View commit details
    Browse the repository at this point in the history
  6. No unsafe

    mxinden committed Apr 4, 2024
    Configuration menu
    Copy the full SHA
    7681cf0 View commit details
    Browse the repository at this point in the history

Commits on Apr 5, 2024

  1. Configuration menu
    Copy the full SHA
    c2b0721 View commit details
    Browse the repository at this point in the history
  2. Prevent busy loop

    mxinden committed Apr 5, 2024
    Configuration menu
    Copy the full SHA
    5d314b6 View commit details
    Browse the repository at this point in the history
  3. fix(http3): don't call stream_has_pending_data on send_data

    `<SendMessage as Sendstream>::send_data` attempts to send a slice of data down
    into the QUIC layer, more specifically `neqo_transport::Connection::stream_send_atomic`.
    
    While it attempts to send any existing buffered data at the http3 layer first,
    it does not itself fill the http3 layer buffer, but instead only sends data, if
    the lower QUIC layer has capacity, i.e. only if it can send the data down to the
    QUIC layer right away.
    
    https://github.com/mozilla/neqo/blob/5dfe106669ccb695187511305c21b8e8a8775e91/neqo-http3/src/send_message.rs#L168-L221
    
    `<SendMessage as Sendstream>::send_data` is called via
    `Http3ServerHandler::send_data`. The wrapper first marks the stream as
    `stream_has_pending_data`, marks itself as `needs_processing` and then calls
    down into `<SendMessage as Sendstream>::send_data`.
    
    https://github.com/mozilla/neqo/blob/5dfe106669ccb695187511305c21b8e8a8775e91/neqo-http3/src/connection_server.rs#L51-L74
    
    Thus the latter always marks the former as `stream_has_pending_data` even though
    the former never writes into the buffer and thus might actually not have pending
    data.
    
    Why is this problematic?
    
    1. Say that the buffer of the `BufferedStream` of `SendMessage` is empty.
    
    2. Say that the user attempts to write data via `Http3ServerHandler::send_data`.
    Despite not filling the http3 layer buffer, the stream is marked as
    `stream_has_pending_data`.
    
    3. Say that next the user calls `Http3Server::process`, which will call
    `Http3Server::process_http3`, which will call
    `Http3ServerHandler::process_http3`, which will call
    `Http3Connection::process_sending`, which will call `Http3Connection::send_non_control_streams`.
    
    `Http3Connection::send_non_control_streams` will attempt to flush all http3
    layer buffers of streams marked via `stream_has_pending_data`, e.g. the stream
    from step (2). Thus it will call `<SendMessage as SendStream>::send` (note
    `send` and not the previous `send_data`). This function will attempt the
    stream's http3 layer buffer. In the case where the http3 layer stream buffer is
    empty, it will enqueue a `DataWritable` event for the user. Given that the
    buffer of our stream is empty (see (1)) such `DataWritable` event is always emitted.
    
    https://github.com/mozilla/neqo/blob/5dfe106669ccb695187511305c21b8e8a8775e91/neqo-http3/src/send_message.rs#L236-L264
    
    The user, on receiving the `DataWritable` event will attempt to write to it via
    `Http3ServerHandler::send_data`, back to step (2), thus closing the busy loop.
    
    How to fix?
    
    This commit adds an additional check to the `has_pending_data` function to
    ensure it indeed does have pending data. This breaks the above busy loop.
    mxinden committed Apr 5, 2024
    Configuration menu
    Copy the full SHA
    158fc73 View commit details
    Browse the repository at this point in the history
  4. Revert "Prevent busy loop"

    This reverts commit 5d314b6.
    mxinden committed Apr 5, 2024
    Configuration menu
    Copy the full SHA
    3beb0c5 View commit details
    Browse the repository at this point in the history

Commits on Apr 6, 2024

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

Commits on Apr 7, 2024

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

Commits on Apr 16, 2024

  1. Configuration menu
    Copy the full SHA
    3f63dc2 View commit details
    Browse the repository at this point in the history
  2. fix(SendMessage): always use available send space

    Always use up send space on QUIC layer to ensure receiving
    `ConnectionEvent::SendStreamWritable` event when more send space is available.
    
    See mozilla#1819 for details. This commit
    implements option 2.
    
    Fixes mozilla#1819.
    mxinden committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    1a7d2bf View commit details
    Browse the repository at this point in the history
  3. Configuration menu
    Copy the full SHA
    38fca6b View commit details
    Browse the repository at this point in the history
  4. Disable pacing

    mxinden committed Apr 16, 2024
    Configuration menu
    Copy the full SHA
    7052274 View commit details
    Browse the repository at this point in the history