Skip to content

Record and analyze Android benchmark runs under Perfetto in one command - #37

Merged
Xget7 merged 3 commits into
perf/android-trace-sectionsfrom
perf/android-perfetto-flow
Oct 20, 2026
Merged

Xget7 merged 3 commits into
perf/android-trace-sectionsfrom
perf/android-perfetto-flow

Conversation

@Xget7

@Xget7 Xget7 commented Oct 20, 2026 •

Copy link
Copy Markdown
Owner

Summary

One command records a release benchmark run under Perfetto on a phone and summarizes it, and an agent skill says how to read and compare runs.

scripts/android_perf.py [--seconds N] [--quality P] [--pose x,y,z,yaw,pitch]
  gradle :app:assembleRelease, adb install       # profileable release, timings valid
  perfetto --background                          # sched, cpufreq, thermal, memory, app slices
  am start --ez benchmark true --ez hud false    # the dev app's fixed-pose turn
  wait for "benchmark gpu ms:" in logcat
  pull trace -> output/android-perf/<time>/{trace.perfetto-trace, logcat.txt, report.json}
  scripts/perfetto_analysis.py --pid <app>       # in build/perf-venv; perfetto==0.57.2
    window = "SplatKit benchmark" async slice
    render-thread slice distributions, submit pacing and hitches,
    thread states per CPU cluster, cluster clocks, RSS, load times
 apps/android-dev/app/src/main/AndroidManifest.xml
+  <profileable android:shell="true" />          # release keeps the library's trace sections
 .claude/skills/android-perf/SKILL.md             # record, read, compare; the noise-floor rule
 .gitignore
-  .claude/
+  .claude/*
+  !.claude/skills/

Evidence

Physical Xiaomi Mi 9 (Adreno 640, Vulkan 1.1.128, Android 11), release build, --seconds 20.

  • Before: a release build showed no app slices, and a manual run took several adb and Perfetto UI steps.
    After: python3 scripts/android_perf.py --seconds 20 ends with:
    status passed; app slices in trace: True
    benchmark window 19.9 s, 905 frames submitted (45.4 fps)
      SplatKit frame                 mean  12.79 ms  p95  24.92
      SplatKit submit and present    mean  10.12 ms  p95  21.91
    pacing: interval p50 16.9 ms, p95 34.4, max 66.8, 283 hitches over 1.5x median
    SplatKitRender: running 14% (cpus 4-6 9%, cpus 7-7 5%); S 84%
    
    The submit-fps reading agrees with the app's own 45.2 fps.
    The run is GPU-bound (21.8 ms against a 16.7 ms budget), so pacing alternates between one and two display periods.
  • One run named the app <pre-initialized> because Perfetto read its /proc entry before the zygote rename, and matching by package name found nothing.
    The analysis now matches the pid the recorder passes, and an earlier trace still analyzes identically by name.
  • python3 -m unittest discover -s scripts/tests: 45 tests pass, including the new config, launch, percentile, cluster, pacing and breakdown tests.

Merge Danger

Door: two-way

Blast Radius: tooling

The library is unchanged; the dev app's release build becomes profileable from a shell, which the dev app never ships.
The .gitignore change starts tracking .claude/skills/, while the rest of .claude/ stays ignored.
The first analysis downloads trace_processor through the pinned perfetto package.

Xget7 added 3 commits October 20, 2026 01:12
Android drops app trace sections from release apps that are neither
debuggable nor profileable, so Perfetto saw none of the library's
slices in an optimized build.
scripts/android_perf.py builds the dev app as release, runs its
benchmark turn while the phone records a Perfetto trace, and writes the
trace, logcat and benchmark_report summary to output/android-perf.
scripts/perfetto_analysis.py then reads the trace with trace_processor:
render thread slices, submit pacing, thread states per CPU cluster,
clocks, memory and world load, over the benchmark slice's window.
The skill runs the two scripts and says how to read each signal for
the Vulkan renderer. .claude/skills/ is now tracked while the rest of
.claude/ stays local.
@Xget7
Xget7 added this pull request to stack #38 October 20, 2026 04:17
@Xget7 Xget7 changed the title perf/android perfetto flow Record and analyze Android benchmark runs under Perfetto in one command Oct 20, 2026
@Xget7
Xget7 marked this pull request as ready for review October 20, 2026 04:21
@Xget7
Xget7 merged commit 22b6504 into main Oct 20, 2026
17 checks passed
@Xget7
Xget7 deleted the perf/android-perfetto-flow branch October 20, 2026 13:23
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