perfetto-sql

Translates natural language intents into Perfetto SQL queries executed against Android trace files.

1|Updated Jun 9, 2026
One-click install
npx skills add https://github.com/kariemSeiam/android-claw --skill perfetto-sql-kariemseiam
Or copy as Structured Prompt for Agent▼
Please help me install this Agent Skill.
Skill: perfetto-sql
Source: https://github.com/kariemSeiam/android-claw/tree/main/skills/installed/profilers-perfetto-sql
Command: npx skills add https://github.com/kariemSeiam/android-claw --skill perfetto-sql-kariemseiam

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve? Analyzing Android Perfetto traces requires deep knowledge of Perfetto SQL syntax, the standard library schema, and pitfalls like overlapping SPAN_JOIN intervals or incomplete slices. This Skill converts plain-language performance questions into validated, executable Perfetto SQL queries against local trace files. ## Core Features & Use Cases - Natural Language to SQL: Translates data intents into syntactically valid Perfetto SQL using the trace_processor engine. - Schema-Grounded Drafting: Searches the bundled Perfetto Standard Library documentation to verify tables, views, and INCLUDE PERFETTO MODULE statements before writing queries. - Validation Loop: Enforces a checklist covering idempotency, GLOB-based string matching, utid/upid joins, SPAN_JOIN partitioning, and dur = -1 handling, with up to three draft-and-fix iterations. - Use Case: Ask how much total time RenderThread slices consumed in a captured trace, and receive a validated query plus CSV results explaining the performance impact. ## Quick Start Ask the assistant to analyze your Perfetto trace file, for example: query my trace.pftrace file and show the total duration of all slices matching RenderThread.

Frequently Asked Questions about perfetto-sql

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

FAQPage Schema
How do I query Android Perfetto traces with SQL?▼

Use the trace_processor wrapper downloaded from get.perfetto.dev and run queries with the --query-string flag against your trace file. This Skill drafts the Perfetto SQL for you, validates it against the standard library schema, and returns results in CSV format.

How to calculate total duration of slices matching a name in Perfetto?▼

Sum durations from the slice table using GLOB for name matching, and handle incomplete slices with IIF(dur = -1, trace_end() - ts, dur). Divide by 1000000.0 to convert nanoseconds to milliseconds.

Why does SPAN_JOIN crash in Perfetto SQL?▼

SPAN_JOIN crashes when intervals within the same input table overlap. Fix it by adding a PARTITIONED clause such as PARTITIONED upid, and materialize intermediate tables with CREATE PERFETTO TABLE instead of CREATE VIEW.

Should I use tid or utid when joining Perfetto trace tables?▼

Always join using utid or upid rather than tid or pid. The operating system recycles thread and process IDs during a trace, while utid and upid remain unique for the trace lifetime, preventing incorrect joins.

Why is LIKE discouraged in Perfetto SQL queries?▼

LIKE causes performance bottlenecks and treats underscores as wildcards, producing incorrect matches. Use = for exact matches and GLOB with * for substring or case-insensitive matching via LOWER(name) GLOB.