perf(retained): pair native-memory rows and observe the viewer's workers (Refs #7955)
Refs #7955 (item 6 qualification). Measurement code only; no thresholds, no plan rules changed.
A non-exclusive pre-flight of the retained qualification runners at the plan's fixture size (advanced_model, Holter) found two gaps in the runners themselves:
-
Native memory rows could never pair.
retained-qual-native-memory.mjsmeasures one process per sample, so a paired cohort is many invocations, andretained-qual-report.mjskeyed rounds by each invocation'sstartedAt. Every base/branch native comparison came outunpaired. The runner now takes--round N --pairing-id ID(both or neither);pairingIdtravels in row provenance, and the reporter pairs by it when present. -
PLAN.md asks for a viewer worker count; only
navigator.hardwareConcurrencywas recorded. The viewer init script now wraps the page'sWorkerconstructor and recordspageWorkersCreated,pageWorkersPeakLive(counted viaterminate()) andpageWorkersByScript. Workers started inside a worker (the SDK's private one) are not visible, and the row says so. -
The viewer's
--timeout-mscould not fire on a saturated page (second commit,b26de88ea0). Playwright polls thewaitForFunctionpredicate inside the page. In the Holter pre-flight the renderer's main thread stayed busy past 70 min and the 60-min timeout never triggered, which would hang a whole cohort. The wait is now also bounded from Node (raceWithTimeout, as browser-memory already does), so a stuck page becomes a failed row and the browser is closed. A regression test covers it.
Verification:
node --test scripts/perf/*.test.mjs: 304 pass, 0 fail (head79ee0adcf9);retained-qual-*87/87 atb26de88ea0. New tests cover pairing-id pairing (and its absence),--round/--pairing-idvalidation, and worker counting in the page script.- Real viewer on Pop (headed Chrome on a private Xvfb, hardware nvidia/lovelace adapter, retained engine, advanced_model, one non-exclusive round): sample OK; 4 page workers (parser, retained, source-identity, source-compression), peak 3 live.
node scripts/pre-handoff.mjs --base origin/main: all gates pass. "retained-free viewer" was SKIPPED because there was no default viewer build in the checkout; CI runs it.
š¤ Generated with Claude Code
Summary by CodeRabbit
- New Features
- Performance reports include page-created worker counts, peak live workers, and per-script totals.
- Native memory samples can be paired across separate runs using a shared pairing ID and round number.
- Bug Fixes
- Performance comparisons group samples more consistently, and viewer sampling enforces its timeout when a page is unresponsive.
- Documentation
- Clarified worker measurement limits and native memory pairing requirements, including the need for an identified host.