perfetto-sql

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

3|Updated Aug 4, 2024
One-click install
npx skills add https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform --skill perfetto-sql-kabindra-shrestha
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perfetto-sql
Source: https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform/tree/main/.agents/skills/profilers/perfetto-sql
Command: npx skills add https://github.com/kabindra-shrestha/Clean-Architecture-Kotlin-Compose-Multiplatform --skill perfetto-sql-kabindra-shrestha

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 recycled thread IDs. This Skill converts plain-language performance questions into validated, executable Perfetto SQL queries and runs them against a local trace file. ## Core Features & Use Cases - Natural Language to Perfetto SQL: Drafts syntactically valid queries using schemas from the bundled Perfetto Standard Library reference, with mandatory module includes and alias-prefixed columns. - Guardrailed Query Execution: Runs queries via the official trace_processor wrapper with idempotency rules, GLOB-based string matching, and safe handling of incomplete slices (dur = -1). - Iterative Validation Loop: Validates each query against a checklist covering SPAN_JOIN partitioning, module includes, and schema accuracy, retrying up to three times on failure. - Use Case: Ask how long the RenderThread spent in frames during an app startup trace, and receive a validated SQL query plus CSV results extracted from the trace file. ## Quick Start Ask the assistant to analyze the attached Perfetto trace file and show the total CPU time per thread using this skill.

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 trace_processor with the --query-string flag to run Perfetto SQL against a trace file. Query tables like slice, thread, and sched_slice, joining on utid or upid rather than recycled tid or pid values.

How to analyze app startup time from a Perfetto trace?

Query the android_thread_slices_for_all_startups table for startup requests, then join with slice data to measure durations. Handle incomplete slices where dur equals -1 by substituting trace_end() minus ts.

Why does SPAN_JOIN crash in Perfetto SQL?

SPAN_JOIN crashes when intervals within the same input table overlap. Add a PARTITIONED clause such as PARTITIONED upid to isolate intervals, and materialize intermediate inputs with CREATE PERFETTO TABLE instead of views.

Should I use LIKE or GLOB for string matching in Perfetto SQL?

Always use GLOB instead of LIKE in Perfetto SQL. LIKE causes performance bottlenecks and treats underscores as wildcards; use GLOB with asterisks for substring matches and LOWER(name) GLOB for case-insensitive searches.

What is the difference between utid and tid in Perfetto traces?

utid is a unique thread identifier that remains constant for the trace lifetime, while tid is the OS thread ID that gets recycled. Always join tables using utid or upid to prevent incorrect joins across reused identifiers.