Skip to content

perf(net): share route ranking across announcement cursors - #4634

Merged
kixelated merged 1 commit into
mainfrom
codex/sync-route-selection
Sep 30, 2026
Merged

kixelated merged 1 commit into
mainfrom
codex/sync-route-selection

Conversation

@kixelated

@kixelated kixelated commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

sync_route recomputes the minimum visible route independently for every interested announcement cursor. Duplicate routes at one prefix multiply route ranking work by cursor fanout. Live relay profiles showed this path consuming substantial CPU during mesh announcement churn.

Approach

Rank routes at the changed prefix once, then let each cursor choose its first visible candidate. Preserve scope, split-horizon, hidden and mount filtering. Keep the existing covering-route selection for cursor roots, where multiple prefixes collapse into one presentation. Extract winner delivery into TableCursor::update so both paths share notification behavior.

Add scope/split-horizon and covering-root regression coverage, sparse fanout controls, and a scoped route-repricing benchmark.

Impact

  • No public API or wire changes.

Validation

just fix and just check passed on committed head 41e3c31ef against origin/main. The main Nextest suite passed 4,835 tests; transport and media feature suites passed another 367, 132 and 73 test executions. Linting, drill applicability and Nix checks also passed.

Serial Criterion comparison against d04baef, 20 samples per case with 1 second warmup and measurement, on the same shared Linux host:

Benchmark Before After
Announce, 30 routes / 30 cursors 631.87 µs 80.21 µs
Announce, 240 routes / 240 cursors 39.81 ms 736.95 µs
Reprice, 30 routes / 30 cursors 788.74 µs 69.97 µs
Reprice, 240 routes / 240 cursors 28.97 ms 528.67 µs
Announce, 1 route / 1 cursor 7.94 µs 4.55 µs

All sampled sparse and fleet cases also improved. These are synthetic shared-host measurements, not a demonstrated reduction in production packet loss. The benchmark is covered by the existing nightly origin benchmark smoke run.

Alternatives

Reusing one winner globally would break per-cursor visibility. Persistent sorted state adds mutation bookkeeping; this change keeps ranking local to one synchronization pass.

Follow-ups

Measure production CPU and UDP drops after this lands and is deployed separately. This PR does not change fleet pins or deploy anything. Related planning: #4615.

(Written by GPT-6)

Co-Authored-By: GPT-6 <noreply@openai.com>
@kixelated
kixelated marked this pull request as ready for review September 30, 2026 21:28
@coderabbitai

coderabbitai Bot commented Sep 30, 2026

Copy link
Copy Markdown
Contributor

Warning

Review limit reached

You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository.

Next included review available in 28 minutes.

Check out review usage here.

View limit details

Limit details: You’ve used all 4 included reviews currently available.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Advanced

Run ID: 537ff279-7d0a-4975-adce-8f1f85eac8b2

📥 Commits

Reviewing files that changed from the base of the PR and between d04baef and 41e3c31.

📒 Files selected for processing (2)
  • rs/moq-net/benches/origin.rs
  • rs/moq-net/src/model/origin.rs
  • Autopilot · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

Autopilot is currently an internal CodeRabbit preview.


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.

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Reviewed for equivalence with sync_cursor; no findings.

  • A non-empty presented only arises when prefix sits strictly under the cursor root, so root.join(presented) == prefix and every routes.at(prefix) entry shares one length. The old longest-prefix filter was a no-op there, and "first visible in route_order" equals the old per-cursor min_by_key over visible entries.
  • route_order ends in Reverse(entry.id), so the order is total and sort_unstable_by_key cannot change a winner on ties.
  • The root case still goes through sync_cursor, which keeps the covering-prefix collapse, and root_cursor_keeps_the_more_specific_covering_route pins it.

This is the duplicates x cursors axis the .stats mesh loads on every edge, so moq.pro wants to pin it as soon as it lands.

(Written by Claude Opus 5.5)

@kixelated kixelated left a comment

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Automated review by review (OpenAI)

Reviewed commit: 41e3c31ef7d53edcc4db6ac9131e7dfd9c0542d2

No actionable bugs found. I independently confirmed the existing equivalence review. The delivery helper is an unchanged extraction apart from its receiver.

Direction: keep the pass-local ranking. It avoids repeated ranking-key computation without persistent-index bookkeeping, while preserving per-cursor visibility and the covering-root fallback. Sorting costs O(R log R), and worst-case visibility scanning remains O(R × C); the sparse/fanout controls and scoped repricing benchmark appropriately exercise the tradeoff. No public API or wire change.

Verification: static review of the full diff and surrounding selection/delivery paths, new regression tests, and nightly benchmark wiring. I did not run builds, tests, or benchmarks or reproduce the reported performance figures. CI is still running.

(Written by an OpenAI model)

@kixelated
kixelated merged commit 400b89a into main Sep 30, 2026
7 checks passed
@kixelated
kixelated deleted the codex/sync-route-selection branch September 30, 2026 21:44
This was referenced Sep 30, 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