Skip to content

perf: a noop poll and an unrouted label cost what they did before 11-19 - #9237

Merged
kixelated merged 2 commits into
mainfrom
quest/m0/nightly/shared-bench-regressions
Nov 21, 2026
Merged

kixelated merged 2 commits into
mainfrom
quest/m0/nightly/shared-bench-regressions

Conversation

@kixelated

@kixelated kixelated commented Nov 20, 2026 •

Copy link
Copy Markdown
Collaborator

Finishes quest/m0/nightly/shared-bench-regressions.md.

Problem

Nightly run 44562804083 flagged three Rust shared bench groups against the 2026-11-18 head. Paired local runs (each commit in its own worktree and target dir, alternating old/new per round, through quest gate) found:

  • connection_blocked/*: +25 to 30% on every cell, from moq-dev/moq#9152. The bench moved from the waitless write() to poll_write(noop), and feat(quic)!: stream reads and writes wait instead of failing Blocked #9152's Waits::register inserts a stream's waiter entry and then removes it again when a noop waiter registers nothing. Production pays it too: moq-uring's read fill polls with a noop waiter after its first chunk.
  • stats/presence/*: +45 to 60%, from moq-dev/moq#9126, not the quest's suspect moq-dev/moq#9054 (its 100l cells are flat). feat(moq-net): a relay counts what its route layer does #9126 added a routes object of 20 counters to every label's Presence, and every tick serializes it for every label, though only routing peers ever count one.
  • relay_auth_refresh/1/1: does not reproduce. Across the whole 11-18 to 11-19 window, 4 of 5 paired rounds are within +1.5%; the fifth inflated every cell together, which is host load.

Approach

  • moq-quic Waits::register returns early for a noop waiter, so a poll for the answer alone is one call. With that, a real waiter always leaves a live entry, so the old remove-if-empty check goes. This needs kio::Waiter::is_noop, now public.
  • Presence.routes is skipped when all zero. Rust (#[serde(default)]) and JS (zeros() prefault) readers already read a missing routes as zeros, and moq-json applies RFC 7396 merge patches to the document, so a routes returning to zero deletes the key and reads back as zeros.

Impact

  • kio: new Waiter::is_noop. Additive.
  • Stats wire (presence, totals, bucket tracks): routes is absent while every route counter is zero. Every reader since feat(moq-net): a relay counts what its route layer does #9126 defaults it, and older readers ignore it. doc/concept/stats.md says so.
  • moq-lite wire: none.

Alternatives

  • Building a vacant stream's waits off-map and inserting only if something registered (no kio API). Measured: it recovered about two thirds of the connection_blocked gap, against all of it for the early return, and was more code.
  • Accepting the connection_blocked cost as "the bench now measures more". It measures a waste production also pays, so fixing it was cheaper than arguing it.
  • Skipping every zero counter in Presence. Wider wire change for no measured need; routes is the only group most labels never touch.

Validation

Paired medians (Criterion point estimates, 3 rounds unless noted):

Bench pre-culprit main this PR
connection_blocked/live_1/churn_256 13.6 to 14.1 µs 17.1 to 21.1 µs 14.5 to 17.3 µs
connection_blocked/live_1024/churn_256 11.5 to 13.9 µs 14.5 to 15.9 µs 12.1 to 12.2 µs
connection_blocked/live_64/churn_16 1.04 to 1.11 µs 1.21 to 1.33 µs 1.08 to 1.09 µs
stats/presence/100l_0h (2 rounds) 35.4 to 35.6 µs 53.1 to 53.2 µs 38.4 µs
stats/presence/100l_100h (2 rounds) 76.4 to 76.7 µs 108.7 to 114.7 µs 81.2 to 81.6 µs
stats/presence/10000l_0h (2 rounds) 5.2 to 6.0 ms 7.6 to 8.9 ms 5.8 to 6.0 ms

stats/presence keeps about +8% over pre-#9126, under the nightly's 10% threshold: the per-session snapshot and sum of the 20 new atomics, which #9126's counters need.

  • New tests: presence_routes_stay_off_the_wire_until_counted (Rust) and a missing-routes case in js/stats stats.test.ts. moq-stats' real-relay presence tests (reheld_wire_presence_refreshes_two_relay_caches and the rest) decode presence frames that now omit routes, and pass.
  • just ci passes (12565 Rust tests, JS, checks).

Caused by

  • moq-dev/moq#9152 - Waits::register inserts and removes a map entry for a noop waiter, +25 to 30% on connection_blocked (found by check)
  • moq-dev/moq#9126 - every label serializes an all-zero routes each tick, +45 to 60% on stats/presence (found by check)

Decisions

  • Made kio::Waiter::is_noop public rather than restructuring Waits::register around a vacant entry; see Alternatives.
  • Closed relay_auth_refresh/1/1 as noise rather than accepting it: it has no culprit to accept it.

Follow-ups

None.

Models

Size: M
Implementer: Claude Code, claude-opus-5-5, unknown effort (arm A)

(Written by Claude Opus 5.5)

Review

Rewritten by quest review after each round.

  • Head: 7889393

  • Base: origin/main at 847fe82

  • Risk: high, Omitting zero-valued `routes` changes the serialized stats wire format and could break consumers that require the field; reverting restores future output but cannot retract frames already sent.

  • Classified: high by Codex, gpt-6.1-sol, low effort, session 01a1faad-ef4f-7900-a4ec-194aa3fc005b

  • Reviewer: Codex, gpt-6.1-sol, high effort

  • Session: 01a1faae-05e5-7751-b8b0-c100b089a1ee, round 1

  • Score: 9/10, No actionable defects were found: no-op polling preserves live waiters and both readers default omitted route counters to zero, but runtime validation remains pending because builds and tests were not run.

  • Rounds: 1; first round 0; findings 0: fixed 0, refuted 0, open 0

  • Findings: none

kixelated and others added 2 commits November 20, 2026 10:19
A blocked write polled with a noop waiter no longer inserts and removes a
stream's waiter entry, and a presence readout omits an all-zero `routes`,
which readers already default.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@kixelated kixelated changed the title The 2026-11-19 shared-bench regressions are fixed or accepted perf: a noop poll and an unrouted label cost what they did before 11-19 Nov 20, 2026
@kixelated
kixelated marked this pull request as ready for review November 20, 2026 20:39
@coderabbitai

coderabbitai Bot commented Nov 20, 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

  • 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: ef0a813d-542f-42b3-92e9-8bc2fc4513b7
Commits

Reviewing files that changed from the base of the PR and between 9828a20 and 7889393.

Files selected for processing: 7

  • doc/concept/stats.md
  • js/stats/src/stats.test.ts
  • quest/m0/nightly/shared-bench-regressions.md
  • rs/kio/src/waiter.rs
  • rs/moq-net/src/stats.rs
  • rs/moq-net/src/stats/routes.rs
  • rs/moq-quic/src/connection/waits.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

@pullfrog pullfrog 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.

✅ No new issues found.

Approach: sound. Both fixes remove the wasted work where it happens: a noop waiter never touches the stream map, and an all-zero routes is never serialized. Neither adds a mechanism.

Reviewed changes

This run reviewed the full diff of the two-commit branch.

  • Waits::register early return: a noop waiter returns before entry(id).or_default(). A real waiter always leaves an entry in its WaiterList, so dropping the remove-if-empty check is safe. wake still prunes empty entries.
  • kio::Waiter::is_noop made public: an additive API change, needed by moq-quic.
  • Presence.routes skipped when zero: skip_serializing_if = "Routes::is_zero" keeps unrouted labels' routes off the stats wire. Readers already default a missing routes, and the change is documented in doc/concept/stats.md.
  • Tests: a Rust round-trip test covers omitted and counted routes, and the JS schema test covers a missing routes.

Pullfrog  | View workflow run | Using claude-opus-5-5 | 𝕏

@kixelated
kixelated added this pull request to the merge queue Nov 21, 2026
Merged via the queue into main with commit ba44b82 Nov 21, 2026
10 checks passed
@kixelated
kixelated deleted the quest/m0/nightly/shared-bench-regressions branch November 21, 2026 00:57
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