CVPN-2546: Use connected UDP socket on macOS#434
Open
kp-thomas-yau wants to merge 2 commits into
Open
Conversation
a7eb1e8 to
13f4e3e
Compare
|
Code coverage summary for 6621261: ✅ Region coverage 68% passes |
13c4201 to
0d0fdca
Compare
0d0fdca to
0bdd7f8
Compare
Using connected UDP socket on macOS improves upload speed by around 200Mbps when tested with a 10Gbps line. This also exposes a new interface to call connect() again whenever there's a network change on the client side so we can refresh the routes.
The reconnect of the socket runs from the route manager's monitoring loop, just after the /32 server route is refreshed, so connect() resolves via the new path. In NoExec mode (no route management) it is driven directly off a client-supplied network change signal. Connected-send is only enabled when one of those drivers exists; otherwise the socket keeps using send_to.
0bdd7f8 to
c7f91bd
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
On macOS this switches the outside UDP socket's send path from send_to to a connected socket (connect + send), so the kernel resolves the route once at connect time and each send skips the per-packet route lookup. In testing on a 10 Gbps line this improved upload throughput by ~200 Mbps. The downside of a connected socket is that it caches the route to the current egress interface, so the socket is re-connect()-ed whenever the network changes — driven from the route manager's monitoring loop just after the /32 server route is refreshed (or, in NoExec mode, directly off a client-supplied network change signal). Connected-send is only enabled when one of those reconnect drivers exists; otherwise the socket keeps using send_to.
All of the connected-socket behaviour is #[cfg(macos)]-gated, so other platforms are unchanged and the shared RouteManager stays platform-neutral. This PR only changes macOS platform, iOS/tvOS upload speed is relatively okay right now, would explore updating iOS/tvOS in the future.
Motivation and Context
Upload speed improvements on macOS
How Has This Been Tested?
Tested locally, speed improvements up to 200 Mbps most of time when tested with 10 Gbps
Types of changes
Checklist:
main