perfetto-trace-analysis

Analyzes Perfetto .pftrace traces from Lens Studio to identify frame bottlenecks and jank.

16|2|Updated Apr 13, 2026
One-click install
npx skills add https://github.com/lens-studio-devs/ls-extensions --skill perfetto-trace-analysis-lens-studio-devs
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perfetto-trace-analysis
Source: https://github.com/lens-studio-devs/ls-extensions/tree/main/plugins/ls-clad/skills/perfetto-trace-analysis
Command: npx skills add https://github.com/lens-studio-devs/ls-extensions --skill perfetto-trace-analysis-lens-studio-devs

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill requires perfetto, pandas, and includes references (resource) components.

What problem does it solve? Lens Studio performance traces (.pftrace files) are large binary recordings that are not human-readable, making it hard to know why a Lens is slow. This Skill analyzes the trace in-chat and explains which operations are expensive, on which thread, and whether the problem is consistent jank or occasional spikes. ## Core Features & Use Cases - Automated Anomaly Detection: Surfaces slow frames, shader compilation spikes, Lens Activation Time (LAT), and thread hotspots via a single JSON summary script. - Automated Root Cause Analysis: Ranks likely bottleneck drivers with confidence labels and maps generic component names to real scene objects when the Lens Studio MCP is connected. - Deep SQL Drilling (Phase 2): A persistent trace query server with pre-written SQL recipes enables hierarchical call-stack and CPU scheduling investigation when the summary is insufficient. - Use Case: You profile a Lens on Spectacles and get a 200MB .pftrace file. Run this Skill to learn that shader compilation under a specific visual component is driving your worst frames, then get ranked fix suggestions without opening any external profiler UI. ## Quick Start Analyze the attached trace file capture.pftrace and tell me why my Lens is dropping frames.

Frequently Asked Questions about perfetto-trace-analysis

High-intent search queries and answers about installing and using this skill.

FAQPage Schema
How do I analyze a .pftrace file from Lens Studio?

Run the analyze_lens_trace.py script with the trace file path to get a structured JSON summary of slow frames, top slices, thread activity, and frame timing percentiles. Install the perfetto Python package first using the provided requirements file.

How to find frame drops and jank in a Perfetto trace?

The analysis detects depth-0 slices exceeding the frame budget (16.7ms for Spectacles at 60fps, 33.3ms for mobile at 30fps) and reports p50/p90/p99 frame timing stats. A large p50-to-p90 gap indicates spike-based jank, while consistently high p50 means the main render path is too slow.

Does this work with both Spectacles and Mobile Lens Profiler traces?

Yes, the script auto-detects the capture profile by scoring keywords in thread names, slice names, and metadata, with a confidence level. Spectacles traces use a 16.67ms frame budget while mobile traces use 33.3ms.

What Python dependencies are needed for Perfetto trace analysis?

You need Python 3.9 or later with perfetto (version 0.16.0+) and pandas, installable from the included requirements-perfetto.txt file. The perfetto library loads the binary trace into an in-memory SQLite database, and pandas formats query results as CSV.

When should I use deep SQL queries instead of the JSON summary?

Use Phase 2 SQL drilling when slice names are too generic, you need the call hierarchy inside a slow operation, you suspect CPU scheduling preemption, or capture profile confidence is low. If the JSON summary already supports concrete optimization fixes, stop at Phase 1.

Why does the trace server require python -u to run?

The -u flag disables Python's stdout buffering, which is mandatory because buffered output can deadlock the pipe between the server and the querying process. The server communicates over stdin/stdout using a line-based protocol terminated by END_OF_QUERY.