perfetto-sql

Translate natural-language performance intents into Perfetto SQL queries and execute them on trace files.

6.6k|388|Updated Mar 16, 2026
One-click install
npx skills add https://github.com/android/skills --skill perfetto-sql-android
Or copy as Structured Prompt for Agent
Please help me install this Agent Skill.
Skill: perfetto-sql
Source: https://github.com/android/skills/tree/main/profilers/perfetto-sql
Command: npx skills add https://github.com/android/skills --skill perfetto-sql-android

SYSTEM DOCUMENTATION & REQUIREMENTS

💡 This Skill includes references (resource) components.

What problem does it solve?

This Skill helps you turn natural-language performance questions into correct, executable Perfetto SQL that extracts timing and memory-related signals from Android Perfetto trace files.

Core Features & Use Cases

  • Natural-language to Perfetto SQL translation: Convert an intent like “CPU frequency around timestamp T” into valid Perfetto SQL that you can run with trace_processor.
  • Safe, reusable query generation: Enforces idempotent creation patterns (CREATE OR REPLACE / DROP + re-create for virtual tables) to prevent re-run failures.
  • Correct trace-time handling: Produces robust logic for open-ended intervals (dur = -1) using trace_end() - ts, and encourages using standard library modules instead of brittle manual arithmetic.
  • Perflog extraction targets: Extract slice/thread-related data (including startup-focused queries like android_thread_slices_for_all_startups) and counter/counter_track values for named counters.

Quick Start

Ask it to “Extract the total duration in milliseconds of slices whose name matches RenderThread from the provided Perfetto trace, and include the trace_end() handling for any slices with dur = -1.”

Frequently Asked Questions about perfetto-sql

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

FAQPage Schema
How do I write Perfetto SQL to extract RenderThread slice durations from an Android trace?

To write Perfetto SQL for extracting RenderThread slice durations, translate natural language intents into queries targeting the slice table. You filter by name matching 'RenderThread' and calculate duration, using trace_end() - ts for any slices with dur = -1.

What is the correct way to handle dur = -1 for trace intervals in Perfetto SQL?

Handling dur = -1 in Perfetto SQL requires calculating the interval using trace_end() - ts. This ensures robust trace-time handling for open-ended intervals instead of relying on brittle manual arithmetic or standard library modules.

How do I execute idempotent Perfetto SQL queries against a local trace file?

Executing idempotent Perfetto SQL queries against a local trace file requires enforcing safe creation patterns like CREATE OR REPLACE or DROP and re-create for virtual tables. This prevents re-run failures during trace_processor extraction.

Can I convert natural language performance questions into executable Android profiling queries?

You can convert natural language performance questions into executable Android profiling queries by translating intents into syntactically valid Perfetto SQL. This extracts timing and memory-related signals like counter values and thread slices from Perfetto traces.

Does Perfetto SQL support extracting memory counter values for named counter tracks?

Perfetto SQL supports extracting memory counter values by querying the counter and counter_track tables. You can target named counters specifically to pull memory-related signals from your local Android Perfetto trace file.

Why do my Perfetto SQL virtual table queries fail when run multiple times?

Perfetto SQL virtual table queries fail on multiple runs if they lack idempotent creation rules. Enforcing CREATE OR REPLACE or DROP and re-create patterns before executing trace_processor queries prevents these re-run failures.