ts_netstack_smoltcp{_core}: improve netstack accept rate, drain closes#141
Merged
dylan-tailscale merged 1 commit intomainfrom Apr 28, 2026
Merged
ts_netstack_smoltcp{_core}: improve netstack accept rate, drain closes#141dylan-tailscale merged 1 commit intomainfrom
dylan-tailscale merged 1 commit intomainfrom
Conversation
dylan-tailscale
commented
Apr 24, 2026
dylan-tailscale
commented
Apr 24, 2026
dylan-tailscale
commented
Apr 24, 2026
npry
requested changes
Apr 24, 2026
Collaborator
npry
left a comment
There was a problem hiding this comment.
Good work on these — the one change I'd push for is splitting the accept queue from the half-open queue, if you agree
87196e8 to
4798ff1
Compare
4798ff1 to
c4ae16b
Compare
npry
approved these changes
Apr 27, 2026
Collaborator
npry
left a comment
There was a problem hiding this comment.
changes look good! just the one note
Moves listening sockets to a new half-open queue when they reach SYN-RECEIVED then moves those to the accept queue when they become ESTABLISHED. This opens a new listening socket ready to accept connections from a new remote much earlier than before, meaning there's a much shorter gap where no socket is actually listening on the port. Previously, this gap was mostly responsible for the poor accept rate; under heavy accept load, many potential clients would get a RST while the previous listening socket was stuck in SYN-RECEIVED waiting to transition to ESTABLISHED. This improved the accept rate to ~60% under heavy load; adding calls to pump_tcp_accept() whenever polling resulted in a changed socket state improved the accept rate to 99%+. Finally, drains the queue of pending TCP closes on the async side of the netstack; previously, the pending closes were never drained when running the netstack async. Signed-off-by: Dylan Bargatze <dylan@tailscale.com>
c4ae16b to
3f36056
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.
Moves listening sockets to the accept queue when they reach
SYN-RECEIVED(orSYN-SENT) rather than waiting for them to become ESTABLISHED. This opens a new listening socket ready to accept connections from a new remote much earlier than before, meaning there's a much shorter gap where no socket is actually listening on the port. Previously, this gap was mostly responsible for the poor accept rate; under heavy accept load, many potential clients would get aRSTwhile the previous listening socket was stuck inSYN-RECEIVEDwaiting to transition toESTABLISHED.This improved the accept rate to ~60% under heavy load; adding calls to
pump_tcp_accept()whenever polling resulted in a changed socket state improved the accept rate to 99%+.Finally, drains the queue of pending TCP closes on the async side of the netstack; previously, the pending closes were never drained when running the netstack async.
Closes #28 .