Skip to content

perf(web): reduce relay probes and defer unused leaf endpoints - #7890

Merged
CommaBot merged 1 commit into
mainfrom
perf/web-relay-overhead
Nov 21, 2026
Merged

CommaBot merged 1 commit into
mainfrom
perf/web-relay-overhead

Conversation

@CommaBot

@CommaBot CommaBot commented Nov 21, 2026 •

Copy link
Copy Markdown
Collaborator

Stable browser sessions repeatedly probe equivalent relay entrances and bind leaf endpoints that a one-station workspace never uses. This change reduces that work while retaining the existing full relay set, application ping cadence, and station admission rules.

  • Pin iroh to 0d8d64f82289a6726cd7edb1671d38a1ce56d0fc in all four manifest/lock pairs. Stable entrance probes back off from 30 seconds to 5 minutes. An entrance switch must clear the 10 ms minimum gain as well as the existing relative margin. Network changes and failures wake probing promptly.
  • Use NetReportConfig::minimal() for browser main endpoints. Their relay-only setup does not need the redundant HTTP latency reports to select a UDP route.
  • Bind a mesh leaf scope on the first descriptor-bearing peer dial, rather than on receipt of its policy stream. Keep receiving policy updates before binding; retain authenticated attachment checks, update handling, and scope cleanup.

The real-browser measurement fixture lives under client/core-ts/side, outside deterministic unit tests. RELAY_LOAD_CUT=dual adds the simultaneous two-relay failure case: one request per station through production MeshWire, per-station event delivery, a path timeline, and optional strict assertions for connection and event-stream continuity after saving the result. It introduces no production hot-set policy.

Measurements

All measurements below ran on the same Tokyo Mac with Chromium Headless Shell 153.0.8010.12, six logical relays and two alternate entrances. Relays and native stations were on loopback (ws/local-loopback). These numbers do not establish TLS, public-network, mobile, or physical-device performance. Historical comparisons isolate the retained changes; they are not new measurements of this rebased commit.

Change and named runs Before After Recovery and scope
Entrance probes, relay-long-merged/{baseline,merged}, W1/S2/visible, 15 minutes 120 short connections; 8/min in the last five minutes 20 short connections; 0.8/min in the last five minutes 3209 → 3103 ms; original connections kept; event streams reopened 0
Main net report, relay-root-only-{baseline,minimal}, W3/S1/visible, 5 minutes, lazy leaf on both sides GET /ping 8.4/min 0/min 3281 → 3244 ms; all six main relays connected before the cut; original connections kept
Lazy leaf, relay-m-w1-s1-visible → relay-leaf-w1-s1-visible, 5 minutes 1 leaf endpoint; socket median 7 0 leaf endpoints; socket median 6 No peer attachment needed; main endpoint remains
Lazy leaf, relay-m-w3-s1-visible → relay-leaf-w3-s1-visible, 5 minutes 3 leaf endpoints; socket median 9 0 leaf endpoints; socket median 6 Same one-station case in three workspaces

The 15-minute probe comparison used client iroh 8ac61479 versus 4b5d5b9b, with the same 4b5d5b9b relay server and fixture hashes. Five-minute short-connection bins were 40/40/40 versus 12/4/4; intervals reached 300 seconds without resetting. It includes the merged iroh fixes, not an isolated experiment on the 10 ms constant. Main socket median stayed 8; no frame-rate reduction is claimed for that item.

The net-report comparison held leaf scopes unused to isolate main endpoint HTTP requests (d37901db15 versus that tree with the minimal-report wasm). Lazy-leaf counts compare baseline b2818f70e9 against d37901db15; there is no steady-state endpoint saving promised when a second station needs an inner route. Earlier S2 fixtures filled peer relay addresses artificially; the committed fixture instead uses native station descriptors unchanged and records them.

Raw JSON, CDP metadata, script hashes, and per-run reports are retained in the measurement chat: relay-retained-raw.tar.gz, relay-long-{baseline,merged}-final.tar.gz, and hot-final-dual.tar.gz.

Six guarantees

  1. End-to-end encryption: relays still forward encrypted packets. No content keys or application access move to a relay. Fewer entrance probes reduce observations; the custom-relay identity change below is explicit.
  2. Cloud remains the account system: no request proxy, routing state, online decision, or measurement state is added to cloud. Mesh operation continues without it.
  3. Station admission: no public station listener or tunnel is added. Station keys, signed member credentials, lock checks, and authenticated leaf attachments still govern access. Descriptor-bearing attachment failures do not fall back to an unauthenticated route.
  4. Workspace relay policy: Mesh.#mainOn, fenced/pinned endpoint routing, and workspace off lists are unchanged. Lazy binding passes the current scope policy to native validation before creating a route. iroh allowlists remain a ceiling for learned addresses; explicit removal and per-peer disabling cannot be bypassed by fallback transport selection.
  5. Public transit: browsers remain transit: false. Direct-neighbor authentication and bounded signed proofs remain unchanged; self-signed identity does not grant workspace access.
  6. No internal polling: production policy updates stay on streams; no polling timer is added. Entrance probing is transport measurement. Real-time sampling and observation deadlines exist only in the optional side fixture.

Other behavior included by the iroh pin

These apply to native clients and station as well as web; this is not a browser-only dependency update. The existing noq pin stays at main's 63b8fad9.

  • iroh #22: adaptive entrance-probe backoff, reset on candidate observation, address/network changes and connection failure, while keeping temporary probe identities.
  • iroh #23: re-enable shelved per-peer relay paths without addAddr; serialize insert/remove state and preserve path-loss budgets. Removed relays no longer reconnect through a fallback transport.
  • iroh #24: require at least 10 ms and more than 20% RTT improvement for an entrance candidate; retain its documented initial comparison and later two-round hysteresis.
  • iroh #25: make watcher-close and relay-policy test prerequisites explicit, without production timeout or selector changes.
  • iroh #26: endpoints homed on every relay really dial an allowed addressed relay instead of borrowing another relay's connection. Single-home routing stays unchanged; idle non-home dial/backoff actors stop after 60 seconds without outgoing data. Tests stop consulting public discovery and synchronize insert/remove explicitly.

Consequently, an allowed workspace custom relay addressed through the main endpoint can receive a real connection and see the device's main endpoint ID, rather than just a per-relay pinned identity. This can add one shared connection per distinct custom URL on that endpoint. Keepalives count as outgoing data and keep it alive; idle cleanup does not remove an actively used path. Native public-relay emergency fallback also really reaches the requested URL. Allowlist, removed, and per-peer disabled checks still apply. Cold first connections could already dial such URLs before #26; the change removes the cross-relay shortcut after a peer was seen elsewhere.

Deliberately excluded

  • Item 5, skipping application pings while replies arrive, was reverted. Its isolated measurements lost original connections in three of four idle scenarios and did not establish a consistent gain under a continuous downstream stream. Both its original commit and revert disappear from this one-commit history.
  • Item 3, keeping workspace-disabled relays on the main endpoint, and item 7, shrinking hidden pages to one path, are not included.
  • Items 6 and 4, a small resident relay set and two hot paths per station, remain on perf/web-relay-diet-hot for a separate PR after the failure is fixed. The independent counterexample at 9d25bd74 is decisive: simultaneous loss of the two hot relays recovered a request in 13,601 ms, replaced one connection, and reopened one event stream; full-relay control took 3,123 ms, kept connections, and reopened none. Alternatives existed about 0.5 seconds after expansion but the old connection remained selected on a dead path. The side runner's old exit 0 meant eventual delivery, not acceptable continuity. The committed optional scenario records continuity by default and supports strict assertions with RELAY_LOAD_REQUIRE_CONTINUITY=1.

The three optional browser methods (setDisabledRelays, insertRelay, removeRelay) stay in this PR with their measurement cases. They have no production caller here and expose no native-host capability. They prepare the later hot-set work and let the fixture independently test policy-clear and insert/remove recovery. They are not counted as a performance gain. Cases verify all three recovery sequences without address reinsertion, including that inserting a relay cannot bypass a peer's disabled set.

History and validation

The first 13 source commits through 09e17a706e were rebased onto a2e97b3c98; git range-diff marked all 13 =. The squashed index then matched rebased reference 0270201f34 byte for byte (git diff empty). The only additions beyond that reference are four side-fixture files/edits for the requested optional dual fault scenario and its documentation. Production code still matches that reference exactly. One commit is used before the first PR.

Tokyo validation on 0eab183f04 passed: wasm, native mesh addon, core-ts typecheck, and STILLFAIL_CHECK_PART="ts core-tests station core" sh scripts/check.sh full a2e97b3c98..HEAD. This includes core-ts, station MoonBit and usage-stream tests, plus Rust tests for station/native/mesh, mesh transport, and client. The three browser relay-control cases passed. The final change only adds explicit continuity recording/strict modes to the side fixture and its documentation. Final core-ts typecheck and STILLFAIL_CHECK_PART=ts full checks passed on the updated working tree, including the TypeScript tests.

All four native prebuilds built and uploaded successfully in run 44843473219. Native inputs have not changed since that run. After the side-fixture update, the last commit was amended without content or message changes: 2d2535ed86 → 68080b1a5e. git diff is empty and git range-diff reports 1 = 1. This publishes a new head after artifacts became available, so its first pipeline attempt can use them. Local build hooks were skipped because builds and full checks ran on Tokyo.

Dual-failure baseline comparison

The first committed non-hot dual-fault run recovered in 3392 ms but replaced a connection and reopened an event stream. Its continuity assertion failed. We then ran five interleaved samples each on pure main a2e97b3c98 and the retained-change tree b8e3cf6754. Main had only the same untracked side scripts. Both used the same browser and 0d8d64f8 relay server, with R6/E2/S2/W1 visible and a 60-second measurement before each cut.

Run Main request ms, S1/S2 Main same connection, S1/S2 Main reopens Change request ms, S1/S2 Change same connection, S1/S2 Change reopens
1 3137 / 6 true / true 0 3382 / 3637 true / false 1
2 3143 / 10 true / true 0 3373 / 3858 true / true 0
3 3598 / 8 false / true 1 3579 / 6 false / true 1
4 3751 / 3540 true / false 1 3652 / 9 false / true 1
5 3442 / 10 false / true 1 3576 / 3576 false / false 2

Main replaced a connection in 3/5 runs; the change did so in 4/5. Every request returned 200 and every event stream eventually delivered. Seven original continuity assertions failed, and all failures remain in the evidence. These samples establish that connection replacement already occurs on main. They do not establish equal probabilities between versions. Recovery timing is consistent with a race between path recovery and an upper-layer replacement dial; these runs alone do not prove that internal mechanism.

Per the requested baseline comparison, the non-hot dual case now records continuity without failing on those fields. Request and event delivery remain required. RELAY_LOAD_REQUIRE_CONTINUITY=1 restores strict continuity checks for future hot-set regression work. Single-relay continuity assertions are unchanged. The real-network runs were not repeated to obtain passing exits. Evidence: web-overhead-dual-compare.tar.gz in the measurement chat. No physical-device or public-network validation was performed.

Models: OpenAI Codex for implementation, review, and independent measurements; carbon supplied the iroh changes and the excluded hot-set work. Test frameworks: Node.js test runner, Effect TestClock and simulated iroh networks, Rust libtest/Tokio, and Playwright/CDP real-browser side measurements.


Start Proof
Open in [code]smith · Need help on this PR? Tag @codesmith-bot with what you need.

Pin iroh across the client and station packages to back off stable relay
entrance probes, including the 10 ms minimum gain for an entrance switch.
Use a minimal net report on browser main endpoints to stop redundant HTTP
relay probes. Create mesh leaf endpoints only when a peer attachment is
needed, and release built scopes when their policy stream ends.

Add a real-browser side fixture, optional wasm relay controls for future
hot-set work, and a simultaneous two-relay failure scenario that checks
connection and event-stream continuity. Keep the production hot-set policy
and the abandoned application-ping optimization out of this change.

Changelog: 改进:减少网页同步时不需要的中继连接和探测请求,降低稳定连接下的中继入口探测频率。
Changelog-parts: station web android desktop
Co-authored-by: darksky <darksky@cue.surf>
@CommaBot
CommaBot merged commit 0b04caa into main Nov 21, 2026
65 checks passed
@CommaBot
CommaBot deleted the perf/web-relay-overhead branch November 21, 2026 01:03
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.

2 participants