Repository navigation
perf(web): reduce relay probes and defer unused leaf endpoints - #7890
Merged
Merged
Conversation
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>
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.
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.
0d8d64f82289a6726cd7edb1671d38a1ce56d0fcin 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.NetReportConfig::minimal()for browser main endpoints. Their relay-only setup does not need the redundant HTTP latency reports to select a UDP route.The real-browser measurement fixture lives under
client/core-ts/side, outside deterministic unit tests.RELAY_LOAD_CUT=dualadds the simultaneous two-relay failure case: one request per station through productionMeshWire, 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.relay-long-merged/{baseline,merged}, W1/S2/visible, 15 minutesrelay-root-only-{baseline,minimal}, W3/S1/visible, 5 minutes, lazy leaf on both sidesGET /ping8.4/minrelay-m-w1-s1-visible→relay-leaf-w1-s1-visible, 5 minutesrelay-m-w3-s1-visible→relay-leaf-w3-s1-visible, 5 minutesThe 15-minute probe comparison used client iroh
8ac61479versus4b5d5b9b, with the same4b5d5b9brelay server and fixture hashes. Five-minute short-connection bins were40/40/40versus12/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 (
d37901db15versus that tree with the minimal-report wasm). Lazy-leaf counts compare baselineb2818f70e9againstd37901db15; 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, andhot-final-dual.tar.gz.Six guarantees
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.transit: false. Direct-neighbor authentication and bounded signed proofs remain unchanged; self-signed identity does not grant workspace access.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.addAddr; serialize insert/remove state and preserve path-loss budgets. Removed relays no longer reconnect through a fallback transport.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
perf/web-relay-diet-hotfor a separate PR after the failure is fixed. The independent counterexample at9d25bd74is 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 withRELAY_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
09e17a706ewere rebased ontoa2e97b3c98;git range-diffmarked all 13=. The squashed index then matched rebased reference0270201f34byte for byte (git diffempty). 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
0eab183f04passed: wasm, native mesh addon, core-ts typecheck, andSTILLFAIL_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 andSTILLFAIL_CHECK_PART=tsfull 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 diffis empty andgit range-diffreports1 = 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
a2e97b3c98and the retained-change treeb8e3cf6754. Main had only the same untracked side scripts. Both used the same browser and0d8d64f8relay server, with R6/E2/S2/W1 visible and a 60-second measurement before each cut.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=1restores 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.gzin 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.
Open in [code]smith · Need help on this PR? Tag
@codesmith-botwith what you need.