Skip to content

perf(ssh): send a single keepalive after wake, not two - #9880

Merged
nwparker merged 1 commit into
mainfrom
nwparker/perf-ssh-wake-keepalive
Jul 22, 2026
Merged

nwparker merged 1 commit into
mainfrom
nwparker/perf-ssh-wake-keepalive

Conversation

@nwparker

@nwparker nwparker commented Jul 22, 2026 •

Copy link
Copy Markdown
Contributor

What

On the first SSH connection-health tick after a sleep/App-Nap wake, the multiplexer sent a keepalive, then detected the wake gap (sinceLastTick > WAKE_GAP_MS), rebaselined liveness, and immediately sent a second keepalive — so every SSH connection emitted two protocol writes per wake.

Fix: on the wake-gap branch, rebaseline lastReceivedAt / unacked timestamps before the tick's single keepalive, then skip the liveness evaluation for that one tick. Net: exactly one fresh probe per connection per wake; the wake is still detected and liveness still rebaselined; steady-state (non-wake) cadence and dead-link detection are unchanged.

ELI5

When your laptop wakes from sleep, Orca pings each SSH connection once to check it's still alive. It was accidentally pinging twice. Now it pings once.

Proof of zero regression

  • The #7773 wake-gap recovery is preserved: lastReceivedAt and every unacked-message timestamp are still reset on wake (just before the single probe instead of around a duplicate one), so a healthy link isn't killed after sleep.
  • Steady-state keepalive cadence and the dead-link check are untouched (only the wake tick changes).
  • Tests: ssh-channel-multiplexer.test.ts 28/28 — tightened to assert exactly one keepalive per cadence tick, added two-connection wake coverage (one probe per multiplexer), and explicit assertions that receive + unacked timestamps are rebaselined on wake. typecheck:node clean.

Proof of perf improvement

Removes one redundant SSH protocol write per connection per wake — the test asserts exactly one keepalive is sent on the post-wake tick (was two). Small but pure wake-cost reduction that scales with the number of open SSH connections.

Made with Orca 🐋

@coderabbitai

coderabbitai Bot commented Jul 22, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro

Run ID: 6fea9202-907d-4d89-a6f8-766ba3f171c4

📥 Commits

Reviewing files that changed from the base of the PR and between e600600 and b7f034a.

📒 Files selected for processing (2)
  • src/main/ssh/ssh-channel-multiplexer.test.ts
  • src/main/ssh/ssh-channel-multiplexer.ts

📝 Walkthrough

Walkthrough

The SSH channel multiplexer now detects long timer gaps after system sleep, refreshes lastReceivedAt and unackedTimestamps, sends one keepalive, and skips dead-link checks for that tick. Tests now verify exact keepalive counts per cadence tick and confirm wake recovery across multiple multiplexers.

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description is detailed but does not follow the required template sections or testing checklist. Reformat it to include Summary, Screenshots, Testing checklist, AI Review Report, Security Audit, and Notes.
✅ Passed checks (4 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly states the main SSH wake behavior change and matches the code changes.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@nwparker
nwparker merged commit 95ae346 into main Jul 22, 2026
2 checks passed
@nwparker
nwparker deleted the nwparker/perf-ssh-wake-keepalive branch July 22, 2026 10:32
enrick-dev pushed a commit to enrick-dev/orca that referenced this pull request Oct 15, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant