1. Tools
- — start profiling on a booted device. iOS: xctrace recording for CPU, hangs, and leaks.
- — stop the profiler and export trace data to timestamped XML files.
- — parse exported trace data and return a structured bottleneck payload.
- — drill into parsed data: hang stacks, function callers, thread breakdown, leak details.
- — list and reload previous trace sessions from disk for re-investigation.
2. Platform Support
- iOS: Fully supported. Backend: Xcode Instruments via on a booted simulator or connected device. Requires Xcode command-line tools on PATH.
- Android: Not yet implemented. An Android backend (Perfetto or simpleperf via ) is planned; today rejects Android serials with a clear "iOS-only for now" error.
3. Investigation Patterns
After
surfaces findings, use
to drill into root causes:
- Hang detected → mode= for full native call chains → mode= for the suspected function → read native source.
- CPU hotspot → mode= for per-thread distribution → mode= for the dominant function.
- Memory leak → mode= filtered by for responsible frames and libraries.
After presenting findings, ask the user whether to investigate further, implement fixes, or stop. After applying fixes, always re-profile the same scenario and compare with
. Report honestly whether the target metric improved, regressed, or stayed flat. If the fix showed no net benefit or introduced regressions elsewhere, say so and reconsider.
Tip: For reproducible before/after comparisons, record the interaction sequence as a flow using the
skill before the first profiling run. Replay with
on subsequent runs to eliminate interaction variance.
Note: The
argent-react-native-profiler
instructs to start native profiling automatically alongside React profiling. This skill's workflow and investigation patterns apply in both cases.
4. Workflow
Complete all steps in order — do not break mid-flow.
Step 0: Ensure the target app is running
The
tool
auto-detects the running app on the device.
You do not need to derive
manually — just make sure the app is launched.
- If the app is already running on the device, skip to Step 1 (do not pass ).
- If the app is not running, use with the correct bundle ID first.
- Only pass explicitly if the tool reports multiple running user apps and you need to disambiguate.
Note: If multiple build flavors are installed (dev, staging, prod), the tool will detect whichever one is currently running. If both are running, it will ask you to specify.
Step 1: Start recording
Call
with
(iOS UDID; Android not yet supported). The tool auto-detects the running app and saves the trace to
/tmp/argent-profiler-cwd/
with a timestamped filename.
Let the user interact with the app or drive interaction via simulator tools (see
skill).
Step 2: Stop and export
Call
with
. On iOS this sends SIGINT to xctrace, waits for trace packaging, and exports CPU, hangs, and leaks data to XML. Check
in the response for any export warnings.
Step 3: Analyze
Call
with
. Returns a markdown report with bottlenecks categorized as CPU hotspots, UI hangs, or memory leaks, sorted by severity.
Step 4: Present findings and ask about next steps
Present a concise summary of the key findings. Then follow the "After analysis" guideline — ask whether to investigate further with query tools, implement fixes, or stop.
Step 5: Drill-down investigation
Use
to investigate specific findings. See §3 Investigation Patterns for chaining guidance.
Step 6: Reload previous sessions
To revisit a previous trace:
- Call mode= to see available sessions.
- Call mode= session_id= device_id= to re-parse the XML files.
- Use to investigate the reloaded data.
5. Understanding Results
Bottlenecks are categorized by severity:
- RED: CPU functions taking >15% of total time, all UI hangs, all memory leaks. These require immediate attention.
- YELLOW: CPU functions taking 5-15% of total time. Worth investigating but may be acceptable.
Each bottleneck type indicates a different class of problem:
- CPU hotspots: Native functions consuming excessive CPU time. Look for tight loops, expensive computations, or redundant work.
- UI hangs: Main thread blocked long enough to cause visible jank or unresponsiveness. Often caused by synchronous I/O, heavy layout passes, or lock contention.
- Memory leaks: Objects allocated but never freed. Common causes include retain cycles, unclosed resources, or forgotten observers.
6. Important Caveats
- Simulator vs device: Simulator profiling reflects host Mac performance, not real device hardware. Use device profiling for accurate CPU timings and memory behavior.
- xctrace availability (iOS): Requires Xcode command-line tools installed. Verify with .
- Profiler overhead: xctrace instrumentation adds CPU load. If , , or Hermes runtime internals dominate the JS thread in CPU hotspot results, those reflect profiler overhead — not app work. Discount those entries when evaluating findings.
- Run-to-run variance: Small fluctuations in CPU percentages between runs are normal. Treat only consistent directional changes (across 2+ runs or >15% delta) as actionable signal.
- Live data variability: If the app fetches live API data, different responses between runs change rendering workload independently of code changes. Note when data-dependent screens show variance.