agentleFS
mirzaaghazadehmirzaaghazadeh/unity-meta-quest-skills/skills/meta-official/hz-simpleperf-debug/SKILL.md

hz-simpleperf-debug

Skill1 starsChanged 30 days agoMITView on GitHub

Profiles Meta VR and Horizon OS application CPU performance using simpleperf — workload classification, CPU hotspot recording, kernel overhead measurement. Use when diagnosing whether an app is CPU-bound, memory-bound, or I/O-bound on Meta VR devices. Build paths: all Meta VR app stacks; use hz-quest-verify-first if the build path is unclear.

2 other projects use a version of this.

Adopted by

Most recently taken up by

The file

We split this skill into the rules it gives an agent

7 rules. About 0 are common, 4 are distinctive, and 3 are very specific to this project.

  • ≈0

    Common · estimate

    Many files like this have a rule of this kind.

  • ≈4

    Distinctive · estimate

    This author's own choices. Worth a look.

  • 3

    Very specific

    Tied to their project's names, files or tools. Probably skip.

  • Common
  • Distinctive
  • Very specific
  1. Distinctive:

    Use this skill when you need hardware-level CPU performance insights on Meta VR devices:

    line 12
  2. Distinctive:

    Before optimizing, determine the bottleneck type:

    line 48
  3. Distinctive:

    Always start with classification.

    line 108
  4. Distinctive:

    If classification shows memory-bound, the issue is likely cache misses or memory bandwidth:

    line 138
  5. Very specific:

    Use Perfetto hz-perfetto-debug to correlate memory-bound regions with specific code paths.

    line 144
  6. Very specific:

    Use metavr perf query to correlate function timing with frame drops

    line 168
  7. Very specific:

    simpleperf requires shell access: If adb shell simpleperf fails, ensure developer mode is enabled and USB debugging is authorized.

    line 174

≈ “Common” is an estimate: at least 1 in 5 of the 350,495 skill files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.

Keep what fits and drop the rest. Your version, ready for your agents.
Files
SKILL.md

Simpleperf Debug Skill

When to Use

Use this skill when you need hardware-level CPU performance insights on Meta VR devices:

  • Classifying whether an app is CPU-bound, memory-bound, or I/O-bound
  • Finding CPU hotspot functions consuming the most cycles
  • Measuring kernel vs userspace CPU overhead per thread
  • Identifying cache-thrashing or branch-prediction issues
  • Supplementing Perfetto trace analysis with hardware PMU counter data

This skill complements hz-perfetto-debug. Perfetto shows what your app is doing over time. Simpleperf shows where the CPU is spending hardware cycles — cache misses, branch mispredictions, and instruction throughput that Perfetto can't see.

VR Performance Context

Meta VR devices run on mobile ARM SoCs with strict thermal and power budgets. CPU-bound apps hit frame drops when:

Refresh RateCPU Frame BudgetNotes
120 Hz8.3 msTight — simpleperf critical for finding hotspots
90 Hz11.1 msDefault target for most apps
72 Hz13.9 msFallback for heavier apps

Simpleperf's hardware counters reveal bottlenecks invisible to software tracing.

metavr Setup

Simpleperf profiling is powered by the metavr CLI — install the standalone binary on your PATH (see the metavr-cli skill), or invoke via npx with no install:

metavr --version

Examples below use the bare metavr command; if you use the npm distribution, prefix with npx -y. Connect your Meta VR device via USB with developer mode enabled.

Quick Start Workflow

1. Classify the Workload

Before optimizing, determine the bottleneck type:

# Classify the foreground app's workload (10-second sample)
metavr perf simpleperf classify

# Target a specific app
metavr perf simpleperf classify --app com.example.myapp

# Custom duration
metavr perf simpleperf classify --duration 15

Returns a classification with evidence:

ClassificationIndicatorOptimization Strategy
CPU-boundHigh IPC, low stall ratioOptimize algorithms, reduce draw calls, batch work
Memory-boundHigh stall ratio (stalled-cycles-backend / cpu-cycles)Reduce cache misses, improve data locality, shrink working set
I/O-boundHigh context switches per secondReduce blocking I/O, use async, minimize thread contention

2. Record CPU Hotspots

Capture a CPU cycle profile to find the most expensive functions:

# Record CPU hotspots for the foreground app
metavr perf simpleperf record

# Custom frequency and duration
metavr perf simpleperf record --frequency 4000 --duration 10

# Target a specific app
metavr perf simpleperf record --app com.example.myapp

The recording samples CPU cycles at the specified frequency (default 4000 Hz) and generates a profile showing which functions consume the most CPU time.

3. Measure Kernel Overhead

Determine how much CPU time is spent in kernel vs userspace per thread:

# Measure kernel overhead for the foreground app
metavr perf simpleperf kernel-overhead

# Custom duration
metavr perf simpleperf kernel-overhead --app com.example.myapp --duration 10

Returns per-thread breakdown of user-mode vs kernel-mode CPU cycles. High kernel overhead (>20%) in a thread suggests:

  • Excessive syscalls (file I/O, memory allocation)
  • Driver overhead (GPU command submission, sensor access)
  • Lock contention in kernel synchronization primitives

Analysis Workflow

Step 1: Classify First

Always start with classification. This prevents wasting time optimizing the wrong thing.

metavr perf simpleperf classify --app com.example.myapp --duration 10

Decision tree based on results:

  • CPU-bound → Record hotspots (Step 2a), look at top functions
  • Memory-bound → Record with cache-miss events, check data access patterns
  • I/O-bound → Check kernel overhead, look at thread contention in Perfetto

Step 2a: CPU-Bound Apps — Find Hotspots

metavr perf simpleperf record --app com.example.myapp --duration 10

Review the top functions by CPU cycle consumption. Common VR hotspots:

Function PatternLikely CauseFix
Physics.* / PhysXComplex physics simulationReduce collider count, simplify meshes, increase fixed timestep
Render* / Draw*Too many draw callsBatch materials, use GPU instancing, reduce unique materials
GC_* / gc_allocGarbage collection pressurePool allocations, avoid per-frame allocations
memcpy / memmoveLarge data copiesUse references, reduce buffer sizes, avoid unnecessary copies
LZ4_* / compressAsset decompressionPre-decompress, use lighter compression, cache results

Step 2b: Memory-Bound Apps — Check Cache Behavior

If classification shows memory-bound, the issue is likely cache misses or memory bandwidth:

  • Large working sets thrashing L1/L2 cache
  • Random access patterns defeating prefetcher
  • False sharing between threads on adjacent cache lines

Use Perfetto hz-perfetto-debug to correlate memory-bound regions with specific code paths.

Step 3: Measure Kernel Overhead

metavr perf simpleperf kernel-overhead --app com.example.myapp

Interpreting results by thread:

ThreadExpected Kernel %High Kernel % Indicates
Main/Game thread< 5%Excessive file I/O, logging, or allocations
Render thread5-15%Normal (GPU driver overhead). >20% = driver issue
Worker threads< 5%Thread synchronization overhead
Audio thread< 10%Normal for audio HAL calls

Step 4: Combine with Perfetto

Simpleperf tells you where cycles go. Perfetto tells you when and in what context. Use together:

  1. Simpleperf classification reveals the bottleneck type
  2. Simpleperf hotspot recording identifies the expensive functions
  3. Perfetto trace (metavr perf capture) shows when those functions run relative to frame boundaries
  4. Use metavr perf query to correlate function timing with frame drops

Common Pitfalls

  • Don't profile in thermal throttling. Let the device cool before recording — throttled clocks distort cycle counts. Check thermal state first with metavr device info.
  • Sample duration matters. Short recordings (<5s) may not capture representative behavior. Use at least 10 seconds for classification.
  • simpleperf requires shell access. If adb shell simpleperf fails, ensure developer mode is enabled and USB debugging is authorized.
  • Frequency vs accuracy tradeoff. Higher sampling frequency (>8000 Hz) can perturb the workload on mobile SoCs. Default 4000 Hz is a good balance.
  • Classification is a snapshot. An app can be CPU-bound during gameplay and I/O-bound during scene loads. Profile the specific scenario you're optimizing.

References

For detailed guides on specific topics, see:

  • Workload Classification — PMU counter interpretation and bottleneck identification
  • CPU Hotspot Analysis — Recording and analyzing CPU cycle profiles
  • Kernel Overhead — Measuring and reducing kernel-mode CPU usage

Download now (ZIP)

Does it work?

Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.

No reviews yet

People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.

  • It worked
  • Partly
  • It didn't
What did you use it for? e.g. Reviewing pull requests in a Rails app

Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.

Your trail

Files you open will collect here, so you can find them again.

Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.

Now do this for your own.

Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.