Skip to content

test(bench): runtime-graph publication probe and optional CDP CPU throttle - #21107

Merged
Jinwoo-H merged 6 commits into
mainfrom
perf/typing-bench-graph-probe
Sep 17, 2026
Merged

Jinwoo-H merged 6 commits into
mainfrom
perf/typing-bench-graph-probe

Conversation

@Jinwoo-H

@Jinwoo-H Jinwoo-H commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor
Files Added Deleted Net
Test 3 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​444 $\color{#cf222e}{\Huge{\mathbf{−}}}$​34 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​410
Prod 1 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2 0 $\color{#1a7f37}{\Huge{\mathbf{+}}}$​2

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, behind ORCA_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.setCPUThrottlingRate around 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

  • Both files are tests/e2e/ plus two lines in the bench runner script; no src/ changes.
  • oxlint clean.
  • Not wired into any CI job — opt-in by environment variable only.
  • typecheck:e2e is red on baseline in this repo and is not a gate, so it is not cited here.

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.

@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 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.ts counts runtime:syncWindowGraph invokes by patching main's private ipcMain._invokeHandlers map, observes renderer longtask entries, 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 — withRendererCpuThrottle wraps the typing window in Emulation.setCPUThrottlingRate (no CDP session at rate <= 1), with withTypingRendererCpuProfile nested inside, wired to two new flags and recorded as cpuThrottleRate.
  • Bench report plumbing — the graphProbe snapshot and graphProbeRequested / cpuThrottleRate config 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 requested busyMs and 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_MS is the only bench knob with no entry in knobByFlag, so the self-test the probe file tells you to run cannot be requested through the runner's documented --flag surface — --graph-probe-selftest-ms 250 falls through to Playwright as an unknown option. Exporting the env var works, but a flag entry would make the documented trigger usable.

Pullfrog  | Fix all ➔ | Fix 👍s ➔ | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@coderabbitai

coderabbitai Bot commented Sep 16, 2026 •

Copy link
Copy Markdown
Contributor

Review Change StackReview Change Stack

Warning

Review limit reached

Next included review available in 8 minutes.

Check out review usage here.

View limit details

Limit 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.

Learn how review limits work.

Review configuration:

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: efea6e9c-04ee-4b41-af67-cb56dfa392fb

📥 Commits

Reviewing files that changed from the base of the PR and between b346433 and cd2321b.

📒 Files selected for processing (1)
  • tests/e2e/runtime-graph-publication-probe.ts
📝 Walkthrough

Walkthrough

The 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 b3464

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)

Check name Status Explanation Resolution
Description check ⚠️ Warning The description explains the scope, mechanism, rationale, limitations, and verification status. However, it does not complete the required template: the linked issue remains Fixes #TBD``, and sections… Replace Fixes #TBD`` with the actual linked issue. Add all required template sections. Mark Visual Proof as N/A with a reason if no UI or interaction changes exist. Document testing steps and platforms, AI disclosure if applicable, review…
Docstring Coverage ⚠️ Warning Docstring coverage is 44.44% which is insufficient. The required threshold is 80.00%. Docstring coverage is scoped to functions touched by this diff. Analyzed 9 functions across 4 files. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title clearly identifies the two main changes: the runtime-graph publication probe and optional CDP CPU throttling.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Full details: Description check

Explanation

The description explains the scope, mechanism, rationale, limitations, and verification status. However, it does not complete the required template: the linked issue remains Fixes #TBD``, and sections such as Visual Proof, Review, Agent skill upstream boundary, Notes, and Checklist are missing or incomplete.

Resolution

Replace Fixes #TBD`` with the actual linked issue. Add all required template sections. Mark Visual Proof as N/A with a reason if no UI or interaction changes exist. Document testing steps and platforms, AI disclosure if applicable, review notes, the agent-skill boundary checkbox, and the checklist items or explain why they do not apply.

✨ Finishing Touches 💡 1
📝 Generate docstrings 💡
  • Create stacked PR
  • Commit on current branch

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.

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

Actionable comments posted: 2


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: b1a94571-9365-4446-9ddd-c95a973761b5

📥 Commits

Reviewing files that changed from the base of the PR and between 9add08b and 3a90386.

📒 Files selected for processing (3)
  • config/scripts/run-multi-workspace-typing-bench.mjs
  • tests/e2e/runtime-graph-publication-probe.ts
  • tests/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.

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

Reviewed changes

  • Reworked the long-task self-test so injectRendererLongTaskSelfTest returns the busy-wait's renderer-clock bounds and the new partitionSelfTestLongTask matches 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 returns appliedCpuThrottleRate; writeBenchReport now records the applied rate instead of the requested global.
  • Added tests/e2e/runtime-graph-publication-probe.unit.test.ts covering the earlier-decoy, unmatched, null, duplicate-identity, and rounding cases for partitionSelfTestLongTask (6 tests, confirmed passing locally).

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

Reviewed changes

  • Failure-path probe cleanup — the hidden-load scenario's finally now calls stopRuntimeGraphPublicationProbe when graphProbeStart is still set, mirroring the instrumentationAvailable cleanup directly above it and swallowing teardown errors so they cannot mask the original failure. The success path still stops the probe before nulling graphProbeStart, so a run stops it exactly once either way.

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

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

Actionable comments posted: 1


ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Advanced

Run ID: 54268bef-f541-44a0-8b68-cff31380c3b0

📥 Commits

Reviewing files that changed from the base of the PR and between 544ea82 and b346433.

📒 Files selected for processing (4)
  • config/scripts/run-multi-workspace-typing-bench.mjs
  • tests/e2e/runtime-graph-publication-probe.ts
  • tests/e2e/runtime-graph-publication-probe.unit.test.ts
  • tests/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.

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

Reviewed changes

  • Drained queued long-task records at probe stop — the renderer probe's stop() now calls observer.takeRecords() and pushes any pending entries into longTasks before observer.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 before disconnect().

Pullfrog  | View workflow run | Using DeepSeek Flash (free via Pullfrog for OSS) | 𝕏

@Jinwoo-H
Jinwoo-H merged commit a634bf9 into main Sep 17, 2026
34 checks passed
@Jinwoo-H
Jinwoo-H deleted the perf/typing-bench-graph-probe branch September 17, 2026 21:32
ivanvykopal pushed a commit to ivanvykopal/orca that referenced this pull request Sep 20, 2026
…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
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