Repository navigation
perf(ssh): relay each session's channels from one event-driven reader and drop the App Nap hold - #4248
Merged
Conversation
datlechin
enabled auto-merge (squash)
November 12, 2026 20:30
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.
Summary
SSHSessionPumpin TableProSSHTransport. Every libssh2 call on a session runs on its serial queue, and after each call the pump serves every channel, becausessh2_channel_readandssh2_channel_writepull every channel's packets off the socket. Readiness comes fromDispatchSourceread and write sources on the transport and local sockets. No 500 ms poll and no thread per relay. The macOS tunnel, Remote SQLite, jump hops and the iOS tunnel all use it.SSHTunnelManagerandRemoteSQLiteTransportManagerno longer hold an activity while a tunnel is open. TCP keepalive runs in the kernel, server requests are answered on transport read events, and the SSH keepalive sleeps until libssh2's next due time (30 s, was a 10 s tick).check-ssh-relay.shmeasures idle wakeups, bulk throughput and latency beside other channels.check-libssh2-keepalive-pending.shshows the wedge. The tunnel matrix harness builds again (stalelocalPort:call, missing LogRedaction source) and can build with-O.SSHChannelRelayTestswent withSSHChannelRelay; every case is ported toSSHSessionPumpTests. TherelayFDStateandtransportPollOutcomecases inRelayPollStateTestswent with those functions.Test plan
apple/scripts/probes/check-ssh-relay.sh, OpenSSH 10 and Redis in Docker, harness built-O, before =origin/main:check-ssh-tunnel-matrix.sh --app macos: 87 of 87, including the loss cells (relaying tunnel notices in 0.0 s, idle one in 59.4 s and 29.8 s, CPU under 0.1 s).check-libssh2-keepalive-pending.sh: after a keepalive whose send blocks, 2,141,640 channel writes are refused in 3 s with the socket writable, and a keepalive from another stack frame does not flush it.swift testTableProSSHTransportTests: 203 pass. New: data another channel's read queued reaches its client with no transport event, an idle relay makes no channel call, local data flows while the client does not read, a relay's half-sent write or window adjust finishes before it ends, a message and an outside call get through beside a socket-limited upload, an upload keeps going beside a channel whose window is closed.LibSSH2KeepAliveTests. iOSbuild-for-testingsucceeds; this Mac has no simulator runtime, so CI runs the iOS tests.Needs the maintainer