Skip to content

perf(net): skip the clock and grace on an unchanged miss probe - #7140

Merged
kixelated merged 5 commits into
mainfrom
quest/m0/nightly/paired-shared
Oct 30, 2026
Merged

kixelated merged 5 commits into
mainfrom
quest/m0/nightly/paired-shared

Conversation

@kixelated

@kixelated kixelated commented Oct 28, 2026 •

Copy link
Copy Markdown
Collaborator

Problem

Fixes the catalog fanout regressions from the Rust shared bench targets nightly, which compared 270395a337 against 22808bbb2f. Completes and deletes quest/m0/nightly/paired-shared.md.

Attribution

The regression is real production work, not a changed workload and not a bad comparison.

  • It reproduces off the runner. I ran the bench's Fanout routine for a fixed number of iterations at each commit and counted user-space instructions with perf stat, pinned to one core type. Setup cost is subtracted. This x86 host matched the ARM runner's wall-clock deltas: hang 1 track/16 readers +22.6%, 1/4 +13.8%, 4/16 +12.0%, MSF 1/16 +18.2%. Current main (53c0dcd685) counts the same as 270395a337.
  • The cost grows with readers, not tracks. Each pending catalog::Consumer::poll_next cost about 1,070 more instructions per reader per rise: 3,830 at base, 4,900 at head.
  • Where the instructions go. A frame-pointer profile shows the new cost in Misses::judge, called from Cursor::probe on every poll_next_group. It reads the wall clock through moq_clock::runtime::read (about 12% of all instructions) and locks the subscriptions for TrackState::arrival_grace (4%). Both happen before it checks whether anything changed.
  • The cause. moq-dev/moq#6921 (6556faf923) moved both reads ahead of that check. The old check, self.at == Some(at) && self.deferred.is_empty(), returned without touching either.
  • Ruled out:
    • HLS records turned on by default (moq-dev/moq#6937) changed the bench's Config::default(), but none of its symbols are hot.
    • Base and current were built with identical features (checked features.txt in the retained bench-rust-shared artifact).

Approach

Misses::judge now checks the cheap terms first: position, budget, ended, and the ledger and drops revisions.

  • When those are unchanged and nothing is deferred, it returns without reading the grace. The grace only sets deadlines on deferred gaps, so with none deferred a new grace has nothing to move. It is picked up the next time something else changes, as a full re-judge.
  • It reads the clock only when a deferred gap has a deadline that could be due, or when there is something to judge.

The new test a_grace_change_with_nothing_deferred_times_the_next_gap covers both halves:

  • an unchanged probe after a grace change skips judging;
  • the next gap's deadline uses the new grace.

Impact

  • Public API: no changes.
  • Wire format and protocol behavior: no changes.

Measurements (instructions per iteration, all 18 shapes)

shape base 22808bbb2f main this PR
hang 1/1 10.87M -1.6% -10.3%
hang 1/4 21.70M +13.8% -3.8%
hang 1/16 68.72M +22.6% +0.4%
hang 4/1 47.78M -6.5% -9.3%
hang 4/4 58.89M -0.9% -6.8%
hang 4/16 106.56M +12.0% -1.7%
hang 16/1 441.40M -2.6% -2.9%
hang 16/4 454.36M -1.2% -2.0%
hang 16/16 509.94M +1.1% -0.8%
msf 1/1 9.34M -7.2% -12.1%
msf 1/4 15.07M +4.9% -7.3%
msf 1/16 39.05M +18.2% -1.3%
msf 4/1 48.13M -6.8% -8.4%
msf 4/4 53.74M -2.8% -6.9%
msf 4/16 78.78M +5.7% -3.3%
msf 16/1 477.20M -2.4% -1.7%
msf 16/4 490.65M -2.4% -3.1%
msf 16/16 522.30M +0.4% -0.2%

Shapes are tracks/readers, with 1,001 estimate rises per iteration. These are instruction counts, not wall time, because about 25 agents share this host.

Checks

  • Current head 4bb5723fa844fae925082459dc5c4c8698761b64: BASH_ENV=/dev/null quest gate just ci origin/main passed in the pinned Nix dev shell against base snapshot c3fcab120688cb00e592895c5930f601c34c5cdb; 8995 tests passed, 96 skipped.

  • Trusted installed quest check --base origin/main --branch quest/m0/nightly/paired-shared, run outside the PR checkout against freshly fetched main (7b840ea5e6b2435d96438803227261a239aaf828): 652 documents passed.

  • Codex completed its review of the current head with no findings; no unresolved review threads remain.

  • cargo test -p moq-net --all-targets after merging main (e34f66847b): 2647 lib tests passed, plus every integration target

  • just ci origin/main on the merged head: 8972 tests passed

  • Merging main needed one test fix: moq-dev/moq#7168 added a named argument to Misses::judge, so the new test now passes None.

  • cargo test -p moq-mux --lib: 1837 passed

  • cargo clippy -p moq-net --all-targets -D warnings: clean

  • cargo fmt --check: clean

  • quest check: clean

Alternatives

  • I skipped the grace lock as well as the clock read. The clock read alone left hang 1/16 at +6%; skipping both brings it to +0.4%.
  • I didn't change the bench. Its workload is unchanged apart from HLS records now being on by default, and that costs nothing measurable here.

Follow-ups

  • Even at base, a pending catalog poll costs about 3,800 instructions per reader. Most of that is Cursor::probe, poll_next_group, poll_drift, sync and live_edge, all running on a track that has nothing new. Readers multiply it, so a cheaper "nothing changed" check across the cursor's poll would lower every fanout shape.
  • bench CI could record instruction counts next to wall time in paired comparisons, which would make findings like this one quicker to attribute.

(Written by GPT-6.1 Sol)

kixelated and others added 2 commits October 28, 2026 15:03
Every catalog subscriber probes its misses on each poll. Since #6921 the
unchanged fast path read the wall clock and locked the subscriptions for
the arrival grace before deciding nothing changed, about 1,070 extra
instructions per pending poll. That is the nightly's catalog fanout
regression: +22.6% at one track and sixteen readers by instruction count.

Read the grace only when a deferred gap could move, and the clock only
when one could be due. Every fanout shape now counts at or below
22808bb.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title Resolve the paired catalog fanout regressions perf(net): skip the clock and grace on an unchanged miss probe Oct 28, 2026
@kixelated
kixelated marked this pull request as ready for review October 28, 2026 22:40
@coderabbitai

coderabbitai Bot commented Oct 28, 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 23 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
  • Source mode: Auto
  • Repository: Unavailable
  • Branch: Unavailable
  • File: No configuration file from this repository applied
  • Commit: Unavailable
  • Layers: Organization UI
  • Review profile: CHILL
  • Plan: Advanced
  • Run ID: cd39462d-e00b-4045-8528-b2ef279453f8
Commits

Reviewing files that changed from the base of the PR and between 66bdbb9 and 4bb5723.

Files selected for processing: 3
  • quest/m0/nightly/README.md
  • quest/m0/nightly/paired-shared.md
  • rs/moq-net/src/model/track/miss.rs
  • Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts

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.

@chatgpt-codex-connector

chatgpt-codex-connector Bot commented Oct 28, 2026 •

Copy link
Copy Markdown

Codex Review Summary

This comment shows the latest Codex review activity on this pull request.

Review Status Commit Review trigger
📝 Code Review ✅ Completed 2026-10-29T15:57:00.116039Z 4bb5723 New commits
ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review" or "@codex security review".

Codex reacts with 👀 while any review is running, comments if it has suggestions, and reacts with 👍 once all reviews finish with no findings.

@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: 12c80a06b1eb8494750edecd11833cf2bcc34fed.

No actionable bugs found. Moving clock/grace reads behind the existing cheap invalidation checks is a proportionate optimization, preferable to a broader cursor-cache redesign here. Empty deferred sets have no grace deadline to move; nonempty sets still check grace changes, future deadlines re-register their wakeup, and due deadlines are judged. The new test specifically checks that skipping a grace-only change does not give the next gap the old grace.

Verification: static review (including an independent review pass) of the diff, miss/deferred logic and relevant track-state helpers. No tests or benchmarks were run, and the reported performance improvements were not independently reproduced.

@kixelated
kixelated added this pull request to the merge queue Oct 29, 2026
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary:

  • Merged main (e34f66847b) into the branch. Git merged it cleanly, but the result didn't compile: moq-dev/moq#7168 added a named: Option<u64> argument to Misses::judge, and this PR's new test still used the old signature. d3eab1780c passes None, the same as the other miss tests. named is only read on the judging path, not in the unchanged early return, so the fix itself is unaffected.
  • Full cargo test -p moq-net --all-targets on the merged head: all passed (2647 lib tests plus the integration targets). just ci origin/main: 8972 passed.
  • Codex reviewed d3eab1780c with no findings. The earlier automated review of 12c80a06b1 also had no findings.
  • quest check --base origin/main --branch quest/m0/nightly/paired-shared: clean.

Landed d3eab1780ccdd34e25833111e06e3caeacf56c25 with the maintainer's approval.

(Written by Claude Opus 5.5)

@github-merge-queue
github-merge-queue Bot removed this pull request from the merge queue due to a conflict with the base branch Oct 29, 2026
@kixelated

Copy link
Copy Markdown
Collaborator Author

Merge summary:

  • Resumed the authorized stale hold and preserved the predecessor's published head, 4bb5723fa844fae925082459dc5c4c8698761b64; no additional source changes were needed.
  • BASH_ENV=/dev/null quest gate just ci origin/main passed in the pinned Nix dev shell against base snapshot c3fcab120688cb00e592895c5930f601c34c5cdb: 8995 tests passed, 96 skipped, with the selected lint, feature, tooling, and quest checks passing. Both Cargo and mbx inherited the fixed startup environment.
  • Re-fetched main at 7b840ea5e6b2435d96438803227261a239aaf828 and ran the trusted installed quest validator outside the PR checkout: 652 documents passed.
  • The pinned head has a completed Codex review with no findings, no unresolved review threads, and all 11 GitHub checks passed. The previous queue removal was a merge conflict; the current head is mergeable.
  • Public API and wire impact: none.

Re-enqueueing this reviewed head under the maintainer's existing merge authorization.

(Written by GPT-6.1 Sol)

@kixelated
kixelated enabled auto-merge October 29, 2026 18:04
@kixelated
kixelated added this pull request to the merge queue Oct 29, 2026
Merged via the queue into main with commit a5a121d Oct 30, 2026
12 checks passed
@kixelated
kixelated deleted the quest/m0/nightly/paired-shared branch October 30, 2026 00:08
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant