Repository navigation
test(bench): runtime-graph publication probe and optional CDP CPU throttle - #21107
Conversation
The build-provided `__orcaBenchmarkInstrumentation` is gone from the tree, so the typing bench could no longer report graph-publication counts at all. The renderer cannot supply them either: `window.api` is frozen by contextBridge, so `runtime.syncWindowGraph` is not wrappable. Count them where they land instead — main's `runtime:syncWindowGraph` invoke handler — behind ORCA_TYPING_BENCH_GRAPH_PROBE=1, and record the result in the bench report. Measured on an 870-worktree fixture: 21 publications over a 50 s metadata-only window versus ~1,205 with recurring OSC title/status traffic. The long-task fields ship unproven: an injected 250 ms renderer busy-wait produced zero entries even though `longtask` is in `supportedEntryTypes`, so their zeros mean "oracle unverified", not "no long task". The self-test knob exists to make that falsifiable, and the file says so; per-publication build time still needs a separate --cpu-profile run.
There was a problem hiding this comment.
ℹ️ No critical issues — a couple of rough edges in the measurement plumbing worth a look.
Reviewed changes
- Runtime-graph publication probe — the new
tests/e2e/runtime-graph-publication-probe.tscountsruntime:syncWindowGraphinvokes by patching main's privateipcMain._invokeHandlersmap, observes rendererlongtaskentries, and surfaces a snapshot; it fails soft to a reason string and states up front that the long-task oracle is unproven. - Optional CDP CPU throttle —
withRendererCpuThrottlewraps the typing window inEmulation.setCPUThrottlingRate(no CDP session at rate <= 1), withwithTypingRendererCpuProfilenested inside, wired to two new flags and recorded ascpuThrottleRate. - Bench report plumbing — the
graphProbesnapshot andgraphProbeRequested/cpuThrottleRateconfig fields are carried into the JSON report.
ℹ️ Nitpicks
injectRendererLongTaskSelfTest's JSDoc says it "Returns the observed duration, or 0 if the observer missed it", but the body always returns the requestedbusyMsand never reads the observer, and the call site (terminal-multi-workspace-typing-latency.spec.ts:467) discards the value. Either make the doc match (it injects, it doesn't observe) or drop the return type.ORCA_TYPING_BENCH_GRAPH_PROBE_SELFTEST_MSis the only bench knob with no entry inknobByFlag, so the self-test the probe file tells you to run cannot be requested through the runner's documented--flagsurface —--graph-probe-selftest-ms 250falls through to Playwright as an unknown option. Exporting the env var works, but a flag entry would make the documented trigger usable.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
|
Warning Review limit reachedNext included review available in 8 minutes. View limit detailsLimit details: You’ve used all 10 included reviews currently available. You've used all free OSS reviews for now. Wait for the free limit to reset to keep reviewing this public repository. Review configuration: ⚙️ Run configurationConfiguration used: Repository UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughThe benchmark runner maps graph-probe and CPU-throttle options to environment variables. The end-to-end benchmark applies optional renderer CPU throttling and runtime-graph publication probing. The probe separates the renderer self-test long task from workload measurements. Reports include the applied throttle rate, probe configuration, and probe results. Unit tests cover self-test task partitioning. Priority: ⬇️ Low Merge Risk: 🔵 Low · up to Optional benchmark reports can undercount a final long task, reducing diagnostic accuracy. Production behavior is unaffected, so this is mergeable with bounded follow-up. 🚥 Pre-merge checks | ✅ 3 | ❌ 2❌ Failed checks (2 warnings)
✅ Passed checks (3 passed)
Full details: Description checkExplanation The description explains the scope, mechanism, rationale, limitations, and verification status. However, it does not complete the required template: the linked issue remains Resolution Replace ✨ Finishing Touches 💡 1📝 Generate docstrings 💡
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. Comment |
There was a problem hiding this comment.
Actionable comments posted: 2
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: b1a94571-9365-4446-9ddd-c95a973761b5
📒 Files selected for processing (3)
config/scripts/run-multi-workspace-typing-bench.mjstests/e2e/runtime-graph-publication-probe.tstests/e2e/terminal-multi-workspace-typing-latency.spec.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 4 remain after this review.
…test caused Two ways the bench could misreport its own conditions. `cpuThrottleRate` was the requested rate, written into every report, but only two of the three scenarios wrapped their typing window in the throttle — a `--cpu-throttle 4` visible-split run claimed a 4x throttle it never applied. Recording the rate per scenario would have made the report honest; it would also have left one scenario silently ignoring the flag, and a fourth scenario would inherit the same omission. So both: every scenario now goes through one `measureTypingWindow` helper, and the value it returns is the rate the throttle actually applied. `writeBenchReport` takes that composite instead of a bare measurement, so a scenario cannot produce a report without saying what it ran under. Unthrottled runs are unchanged — rate 1 still opens no CDP session. `selfTestLongTaskMs` took the *earliest* long task starting before a cutoff captured after the busy-wait. The observer has been live since probe start, so any unrelated long task from fixture setup satisfied it — the field whose whole job is to prove the oracle is live was the easiest one to fake. The busy-wait now reports its own renderer-clock bounds and the matching entry is the one containing their midpoint: main-thread tasks never overlap, so at most one can, and it is the task the busy-wait ran in. That entry is then withheld from `longTasks`, `longestLongTasks`, and `longTasksAroundPublication`, which had been counting the oracle's injected 250 ms as workload. A zero still means "oracle unproven" — it now also means it honestly.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Reworked the long-task self-test so
injectRendererLongTaskSelfTestreturns the busy-wait's renderer-clock bounds and the newpartitionSelfTestLongTaskmatches the entry containing that window's midpoint, then excludes it by identity from every workload summary. - Funneled all three scenarios through
measureTypingWindow, which applies the CDP CPU throttle and returnsappliedCpuThrottleRate;writeBenchReportnow records the applied rate instead of the requested global. - Added
tests/e2e/runtime-graph-publication-probe.unit.test.tscovering the earlier-decoy, unmatched, null, duplicate-identity, and rounding cases forpartitionSelfTestLongTask(6 tests, confirmed passing locally).
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Failure-path probe cleanup — the
hidden-loadscenario'sfinallynow callsstopRuntimeGraphPublicationProbewhengraphProbeStartis still set, mirroring theinstrumentationAvailablecleanup directly above it and swallowing teardown errors so they cannot mask the original failure. The success path still stops the probe before nullinggraphProbeStart, so a run stops it exactly once either way.
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
There was a problem hiding this comment.
Actionable comments posted: 1
ℹ️ Review info
⚙️ Run configuration
Configuration used: Repository UI
Review profile: CHILL
Plan: Advanced
Run ID: 54268bef-f541-44a0-8b68-cff31380c3b0
📒 Files selected for processing (4)
config/scripts/run-multi-workspace-typing-bench.mjstests/e2e/runtime-graph-publication-probe.tstests/e2e/runtime-graph-publication-probe.unit.test.tstests/e2e/terminal-multi-workspace-typing-latency.spec.ts
Included review availability: Your plan provides up to 10 included reviews per hour; 7 remain after this review.
There was a problem hiding this comment.
✅ No new issues found.
Reviewed changes
- Drained queued long-task records at probe stop — the renderer probe's
stop()now callsobserver.takeRecords()and pushes any pending entries intolongTasksbeforeobserver.disconnect(), so long-task entries still queued when the probe is torn down are no longer dropped.takeRecords()empties the queue, so the callback cannot re-deliver the same entries, and the drain runs synchronously beforedisconnect().
DeepSeek Flash (free via Pullfrog for OSS) | 𝕏
…ottle (stablyai#21107) * test(bench): count runtime-graph publications from main The build-provided `__orcaBenchmarkInstrumentation` is gone from the tree, so the typing bench could no longer report graph-publication counts at all. The renderer cannot supply them either: `window.api` is frozen by contextBridge, so `runtime.syncWindowGraph` is not wrappable. Count them where they land instead — main's `runtime:syncWindowGraph` invoke handler — behind ORCA_TYPING_BENCH_GRAPH_PROBE=1, and record the result in the bench report. Measured on an 870-worktree fixture: 21 publications over a 50 s metadata-only window versus ~1,205 with recurring OSC title/status traffic. The long-task fields ship unproven: an injected 250 ms renderer busy-wait produced zero entries even though `longtask` is in `supportedEntryTypes`, so their zeros mean "oracle unverified", not "no long task". The self-test knob exists to make that falsifiable, and the file says so; per-publication build time still needs a separate --cpu-profile run. * test(bench): optional CDP CPU throttle around the typing window * test(bench): report the throttle that ran and the long task the self-test caused Two ways the bench could misreport its own conditions. `cpuThrottleRate` was the requested rate, written into every report, but only two of the three scenarios wrapped their typing window in the throttle — a `--cpu-throttle 4` visible-split run claimed a 4x throttle it never applied. Recording the rate per scenario would have made the report honest; it would also have left one scenario silently ignoring the flag, and a fourth scenario would inherit the same omission. So both: every scenario now goes through one `measureTypingWindow` helper, and the value it returns is the rate the throttle actually applied. `writeBenchReport` takes that composite instead of a bare measurement, so a scenario cannot produce a report without saying what it ran under. Unthrottled runs are unchanged — rate 1 still opens no CDP session. `selfTestLongTaskMs` took the *earliest* long task starting before a cutoff captured after the busy-wait. The observer has been live since probe start, so any unrelated long task from fixture setup satisfied it — the field whose whole job is to prove the oracle is live was the easiest one to fake. The busy-wait now reports its own renderer-clock bounds and the matching entry is the one containing their midpoint: main-thread tasks never overlap, so at most one can, and it is the task the busy-wait ran in. That entry is then withheld from `longTasks`, `longestLongTasks`, and `longTasksAroundPublication`, which had been counting the oracle's injected 250 ms as workload. A zero still means "oracle unproven" — it now also means it honestly. * test(bench): stop the graph probe when the typing run throws * test(e2e): drain queued long-task records before the probe disconnects

Test-only. No production code. Nothing runs by default.
Two pieces of measurement machinery that came out of the typing-latency attribution study, split from the product change (#TBD) so they can land on their own merit.
1. Runtime-graph publication probe
tests/e2e/runtime-graph-publication-probe.ts, behindORCA_TYPING_BENCH_GRAPH_PROBE=1.Counts runtime-graph publications from the main process during a typing bench run and attributes them to a frame class. This is what let the attribution study conclude that graph publication is 14.3% of renderer CPU and 6.3% of long-task time — i.e. that it is not the typing bottleneck.
The probe documents a limitation in itself: its long-task oracle failed its own presence self-test, so a zero from that oracle means "oracle unverified", not "no long task". That is written into the file rather than left for a future reader to discover. A measurement tool that quietly reports a confident zero is worse than no tool.
2. Optional CDP CPU throttle
Emulation.setCPUThrottlingRatearound the typing measurement window, opt-in via the bench script.The typing regression reproduces differently on weaker hardware, and every measurement so far is from one M-series machine. Throttling lets the same fixture stand in for a slower CPU without needing the slower CPU.
Why land this separately
The product optimization it was built to measure is a separate PR, and may or may not land. This machinery is worth keeping either way: it is the only way anyone re-measures this subsystem later, and rebuilding it from scratch next time costs more than reviewing it now.
Verification
tests/e2e/plus two lines in the bench runner script; nosrc/changes.oxlintclean.typecheck:e2eis red on baseline in this repo and is not a gate, so it is not cited here.