Repository navigation
feat(scripts): mobile:metrics benchmarks thread switches, tabs and memory on pool devices - #42975
Open
juliusmarminge wants to merge 14 commits into
Open
juliusmarminge wants to merge 14 commits into
juliusmarminge wants to merge 14 commits into
Conversation
… client memory Nothing measured client wall-clock, CPU or memory in the real app, while a desktop trace showed thread switches costing 110-330 ms, mostly forced layout, timeline/composer rebuilds and the right panel. `vp run report:client` builds the web app for production, serves it from a server on an isolated base dir seeded through the CLI with replayed threads (two new dev-replay recordings: a heavy turn and a long stream), a branch with a 40-file diff and a pull request on the fake GitHub, which now also answers activity, file stats and the REST files list. Headless Chromium switches threads by real sidebar clicks and records click-to-paint, first-frame content, long animation frames, heap/DOM after GC, renderer CPU while a thread streams, and with --trace the forced style/layout call sites mapped through sourcemaps. `ab` alternates two checkouts and `compare` gates the medians, reusing server-metrics' A/B rounds and machine watch. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…d CPU by source Switches alone missed regressions in typing, scrolling, the palette, panel tabs, the terminal and Settings, and timing noise hid small render regressions. - Interaction cases, selectable with --cases (or the switches/interactions groups): composer typing on a short and a long thread, wheel-scrolling the long timeline, the command palette, PR panel tabs, switching between two surfaces, the terminal drawer, and Settings and back. Each step records input-to-paint, LoAF and missed frames. - --renders counts React commits and component renders per step with their top components and causes; --slot-diff deep-diffs named components' hook slots; --unminified builds with readable names. compare gates on renders. - --trace now carries a CPU profile: per marked step, the input task's forced style/layout, self time by package, inclusive time by source file and library (once per sample), and the long tasks that follow. - Panel surfaces record their DOM size, with a census in the artifacts. - --soak repeats every case and fits heap/DOM/listener growth. - noise derives per-metric floors from A/A runs; compare/ab --floors use them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…s and floors Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Sub-16 ms paints count as 16 ms instead of dropping out of comparisons; result files record their workload and compare refuses mismatched ones. Switch timings start at the page's own click timestamp, long frames are clipped to the window, and a switch that does not reach its thread fails the run. The working-thread CPU windows are dropped once the replayed turn has finished. Seeding errors no longer echo process output or the pairing token. The fake GitHub refuses the diff media type with 406, as GitHub does for large diffs. Slot diffs show deleted Map keys, anonymous components count, and --cases rejects inherited names. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
compare takes each run's median as one sample and gates only with two or more runs a side, so one page's samples never pass for independent runs. The trace reports the median of each window's forced total, never borrows a worker's profile, and counts only long tasks after the input task. A failed step stops its frame loop and render probe, and its render readings and traced windows are dropped. A panel that cannot open skips only the cases that need it. Event Timing and long-frame entries are kept only while a measurement watches, so soak heap samples hold none. noise refuses A/A pairs whose probe or build settings differ. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…content by paint Thread ids like `mcp:<uuid>` are percent-encoded in the route, so the new route checks decode it. Content time reads the clock when the frame's callback runs: a frame's begin time can precede the click whose long task delayed it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…m through Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ns after palette A soak's heap kept growing ~1 MB per iteration for dozens of iterations, which the verdict called a leak. Heap snapshots showed it was V8 compiled code while app objects stayed flat. The soak now runs in a second pass whose Chromium has V8's compiling tiers off (timing runs are untouched), and the verdict fits only the soak's later half, where warm-up has settled and a leak keeps its rate. The terminal case was skipped in every combined run: the palette case pressed Escape and waited a fixed 400 ms, and chat shortcuts ignore keys while the palette is still mounted (closing animation included), so Ctrl+J was dropped. The palette case now waits until the palette unmounts. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…cases leave no call sites Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…avior's stack Maintainers had a web client benchmark but nothing to measure the React Native app's thread switching or other interactions. `vp run mobile:metrics` (run, ab, compare, noise, summary) leases a Simlock iOS simulator and reuses mobile:behavior's server, Metro and dev-only probe, now shared through mobile-behavior/session.ts and pool.ts. The probe gains a perf window: JS-side touches, React commits, the commit that first shows a thread's rows (a mark in ThreadFeed), composer keys, JS/UI frames and the Hermes heap, with the render counter for --renders. Cases cover thread switches (short, long, working; first visit and revisit), tabs, the PR list and details on the fake GitHub with client-metrics' 40-file branch, issues, a thread's review sheet, side chats, typing and scrolling. compare/noise reuse client-metrics' bootstrap gate and floors through new series-level helpers. It measures a development build, so counts and A/B differences are representative and absolute times are not. Also fixes the fake GitHub proxy crashing its harness when a refused client resets. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…aks switches, and releases leases on crash Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…etries failed cases each round The issues switcher is a native menu trigger agent-device will not tap by ref, so it is tapped at its labelled view's centre. A failed case no longer drops its later rounds, back tolerates UIKit's unknown outcome mid-pop, and heap samples follow Hermes' own gc(). Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
… fibers Each soak sample also writes the atom registry's nodes by label and mounted fibers by component to soak-retention.ndjson, so heap growth can be told apart from atoms or a growing mounted tree. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Thread transfer impact✅ Thread transfer remains within every enforced ceiling.
Other scenariosNo All 64 scenario measurements
Baseline: unavailable · PR result: Scenario and decoded snapshot size10 historical turns, 5 command tools per turn, 878.9 KiB retained MCP result per historical turn, and a 1.05 MiB retained result in the measured turn.
Updated in place by a trusted workflow. PR artifacts are strictly validated and never executed. |
…e on the dev client The dev build's soak reported about 5 MB of heap growth per iteration that was all dev machinery (the DevTools backend, debugger-enabled Hermes keeping closure locals alive, react-refresh, React's dev debug stacks), and its timings are not representative. `--build release` starts Metro with --no-dev and puts a proxy in front of it that serves the production bundle compiled with the checkout's `hermesc -O`; everything else, inspector sockets included, passes through. The behavior probe is now gated on its env flag alone (store builds inline it unset, so Metro still strips the probe) and stubs React's DevTools hook in production so commits still reach it. Pairing-link prefill and auto-connect allow that same flag, so only the benchmark's bundle gains them. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Nothing measured the mobile app's thread switching, tab switching or memory.
mobile:behaviorchecks that flows work, not how fast they are, and #42606 covers only the web client.Change
vp run mobile:metricsruns onmobile:behavior's stack: it leases a Simlock device, installs the cached build, pairs it with a seeded server and drives it with agent-device. Its seed and fake GitHub are shared withclient-metrics. Lease and session handling moved intoscripts/mobile-behavior/{session,pool}.ts, so both runners share it. Every lease is released when setup fails, and also on a crash.Cases
switch-short,switch-longandswitch-working, first visits and revisits measured separately.pull-request(list and details) andissues.diff(Review changes) andside-chat.typeandscroll-long.What it measures
The behavior probe (
behavior-probe.ts) records:Native menu items (Review changes, the issues switcher) never pass the touch to JS, so their timing starts at the item's JS handler.
--soak <n>repeats the switch cases and samples the Hermes heap after a forcedgc(). It also records registry atoms and mounted fibers tosoak-retention.ndjson, so you can tell a retained-object leak from a growing tree.--build dev|releaseThe pool installs only the dev client.
--build dev(default) runs the development bundle.--build releasestarts Metro with--no-devand puts a proxy in front of it (release-bytecode.ts) that serves the production bundle compiled with the checkout'shermesc -O. Everything else, inspector sockets included, passes through, so the same dev client runs release bytecode. Compiling takes a few minutes per app launch.EXPO_PUBLIC_T3_BEHAVIOR_PROBEalone, not__DEV__. Store builds inline the unset flag, so Metro still strips it: a productionexpo exporthas no probe code. In production bundles it stubs React's DevTools hook so commits still reach it.autoConnect=1are allowed in__DEV__or with that same flag, so only the benchmark's bundle gains them.--renders(rejected), and readable component names in soak retention (minified).abandcomparetreatbuildas part of the workload, so dev and release results never compare.Home rows are now pressed by snapshot ref: a row's label ends in a relative time ("Bench short, 4m") that could tick between reading the screen and the press.
Docs: the "Mobile switch metrics" section of
16_performance-regressions.md.Scope
The maintainer asked for this as the mobile counterpart of #42606, for iterating on mobile thread-switch performance. It is maintainer dev tooling plus probe hooks gated on a flag only the harness sets. Store builds are unchanged.
Verification
vp test run scripts/mobile-metrics/report.test.tscovers the report math;devAutoConnect.test.tscovers the pairing gate in a production bundle with and without the flag.expo exportwithout the flag contains none of the probe's names.--build release --cases switches --rounds 3 --soak 12on an iPhone 18 Pro:Soak: dev growth is dev-only, release is flat
A dev-build
--soakgrows the Hermes heap about 5 MB per iteration. That growth is all dev machinery:In release mode the heap settles and stays flat. Over 12 iterations it went 124, 116, 108, 100, then 92 MB from iteration 4 through 12: 0 MB per iteration over the last half. A rerun on the pushed head with
--soak 6settled at 88–92 MB the same way. Soak in release.Not covered:
Stacked on #42606.
Model and harness: Claude Opus 5.5 in Claude Code (via T3 Code).
🤖 Generated with Claude Code