Skip to content

perf(client-runtime): halve server config bootstrap traffic - #8367

Open
Adamulek123 wants to merge 5 commits into
pingdotgg:mainfrom
Adamulek123:perf/server-config-single-snapshot
Open

perf(client-runtime): halve server config bootstrap traffic#8367
Adamulek123 wants to merge 5 commits into
pingdotgg:mainfrom
Adamulek123:perf/server-config-single-snapshot

Conversation

@Adamulek123

@Adamulek123 Adamulek123 commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

What changed

Client sessions now open subscribeServerConfig once and use its first snapshot for initial configuration. The same stream continues to deliver later configuration updates.

Why

Session startup previously called serverGetConfig and then subscribed to server configuration. The subscription's first frame repeated the same full payload, so every connection paid for two bootstrap exchanges. This change keeps configuration fresh without relying on a cache.

Measured impact

Compared with main-latest.json from main commit 230c5d4a:

Server config bootstrap Main This PR Change
WebSocket wire 10,617 B 5,333 B -5,284 B (-49.8%)
WebSocket decoded 10,597 B 5,323 B -5,274 B (-49.8%)
Messages 4 2 -2 (-50.0%)

The general thread-transfer measurements remain within 0.2% wire variance. Every enforced ceiling passes.

Validation

  • vp test run packages/client-runtime/src/rpc/session.test.ts packages/client-runtime/src/rpc/client.test.ts packages/client-runtime/src/state/server.test.ts, 28 tests passed
  • vp exec tsc -p packages/client-runtime/tsconfig.json --noEmit
  • Focused lint and formatting
  • Deterministic transfer and server-config benchmark guards

Checklist

  • This PR is small and focused
  • I explained what changed and why
  • No UI changes

Generated with GPT-5.6 Sol through the Codex harness.

Note

Reuse session serverConfigEvents stream for subscribeServerConfig to halve bootstrap traffic

  • RpcSessionFactory.make now bootstraps initial config from a streaming subscribeServerConfig snapshot instead of a unary serverGetConfig call, then publishes subsequent updates through a session-level serverConfigEvents stream.
  • subscribeDynamic in client.ts detects the subscribeServerConfig tag and reuses the existing session stream, avoiding a duplicate RPC subscription.
  • New applyServerConfigEvent helper incrementally derives updated ServerConfig from snapshot, keybindingsUpdated, providerStatuses, and settingsUpdated events; mapSessionRpcError maps subscription errors to ConnectionAttemptError.
  • Risk: initial config now depends on receiving a snapshot event from the stream; if the stream ends before a snapshot, the connection fails with a remote-unavailable error instead of falling back to serverGetConfig.

Macroscope summarized 66ee0d2.


Note

Medium Risk
Changes environment connection bootstrap and readiness timing (initial config waits on the first stream snapshot); mistakes could break config sync or duplicate subscriptions, though behavior is heavily covered by tests.

Overview
Session connect now bootstraps configuration from a single subscribeServerConfig subscription instead of serverGetConfig plus a second subscribe, cutting duplicate full-config traffic on connect.

RpcSession forks that subscription once, resolves initialConfig from the first snapshot, and exposes serverConfigEvents as a shared stream (PubSub + replay) that folds keybindingsUpdated, providerStatuses, and settingsUpdated into live config and emits synthetic snapshots when subscribers miss revisions.

subscribeDynamic routes subscribeServerConfig through the session stream when present so callers do not open another websocket subscription. Tests cover no duplicate subscribe, multi-subscriber broadcast/replay, and updated bootstrap expectations.

Reviewed by Cursor Bugbot for commit 66ee0d2. Bugbot is set up for automated code reviews on this repo. Configure here.

@coderabbitai

coderabbitai Bot commented Aug 27, 2026

Copy link
Copy Markdown

Important

Review skipped

Auto reviews are disabled on this repository. Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: efe67bf0-412a-481c-b0ed-6345b2657b90

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review

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

@github-actions github-actions Bot added vouch:unvouched PR author is not yet trusted in the VOUCHED list. size:M 30-99 changed lines (additions + deletions). labels Aug 27, 2026
Comment thread packages/client-runtime/src/rpc/client.ts
@Adamulek123
Adamulek123 force-pushed the perf/server-config-single-snapshot branch from 8aa0532 to 7459715 Compare August 27, 2026 07:32
@Adamulek123
Adamulek123 marked this pull request as ready for review August 27, 2026 07:51
Comment thread packages/client-runtime/src/rpc/session.ts Outdated
@macroscopeapp

macroscopeapp Bot commented Aug 27, 2026

Copy link
Copy Markdown
Contributor

Approvability

Verdict: Not approved

Macroscope's review found this PR not approvable — This changes production connection bootstrap and ongoing server-config delivery by introducing a shared replaying stream with buffering, folding, and new lifecycle/error semantics. The performance gain is well targeted and tested, but the stateful cross-cutting runtime behavior is substantial enough to require human review.

Notes:

  • No code objects were reviewed. Approvability was decided on eligibility alone.

You can add or adjust custom eligibility rules. Learn more.

@github-actions github-actions Bot added size:L 100-499 changed lines (additions + deletions). and removed size:M 30-99 changed lines (additions + deletions). labels Aug 27, 2026
Comment thread packages/client-runtime/src/rpc/session.ts
Comment thread packages/client-runtime/src/rpc/session.ts

@cursor cursor Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Cursor Bugbot has reviewed your changes using high effort and found 1 potential issue.

Fix All in Cursor

❌ Bugbot Autofix is OFF. To automatically fix reported issues with cloud agents, enable autofix in the Cursor dashboard.

Reviewed by Cursor Bugbot for commit 12efd16. Configure here.

Comment thread packages/client-runtime/src/rpc/session.ts Outdated
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L 100-499 changed lines (additions + deletions). vouch:unvouched PR author is not yet trusted in the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant