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: deliver UDP packets from same connection in receiving order #1540

Merged
merged 1 commit into from
Sep 25, 2024

Commits on Sep 25, 2024

  1. feat: deliver UDP packets from same connection in receiving order

    All UDP packets are queued into a single channel, and multiple
    workers are launched to poll the channel in current design.
    
    This introduces a problem where UDP packets from a single connection
    are delivered to different workers, thus forwarded in a random order
    if workers are on different CPU cores. Though UDP peers normally
    have their own logic to handle out-of-order packets, this behavior will
    inevitably cause significant variance in delay and harm connection quality.
    Furthermore, this out-of-order behavior is noticeable even if the underlying
    transport could provide guaranteed orderly delivery -  this is unacceptable.
    
    This commit takes the idea of RSS in terms of NICs: it creates a distinct
    queue for each worker, hashes incoming packets, and distribute the packet
    to a worker by hash result. The tuple (SrcIP, SrcPort, DstIP, DstPort, Proto)
    is used for hashing (Proto is always UDP so it's dropped from final
    implementation), thus packets from the same connection can be sent to
    the same worker, keeping the receiving order. Different connections can be
    hashed to different workers to maintain performance.
    
    Performance for single UDP connection is not affected, as there is already
    a lock in natTable that prevents multiple packets being processed in different
    workers, limiting single connection forwarding performance to 1 worker.
    The only performance penalty is the hashing code, which should be neglectable
    given the footprint of en/decryption work.
    updateing committed Sep 25, 2024
    Configuration menu
    Copy the full SHA
    447e8a7 View commit details
    Browse the repository at this point in the history