Configure Perfetto Locally on Windows via ADB

35 views
Skip to first unread message

Richard Ayala

unread,
Dec 11, 2025, 2:10:28 PM12/11/25
to Perfetto Development - www.perfetto.dev
Hey all, I'm trying to capture a trace via ADB on Windows via the Quickstart guide: https://android.googlesource.com/platform/external/perfetto/+/e74213b02b99a05d2703a41d5543dffa45996d87/docs/quickstart/android-tracing.md

I have successfully pushed the config file towards the bottom of the page: 

adb push config.txt /data/local/tmp/trace_config.txt

However when I attempt to run the next command

abb shell 'perfetto --txt -c - -o /data/misc/perfetto-traces/trace < /data/local/tmp/trace_config.txt'

I'm getting an error: The TraceConfig is empty 

I know perfetto requires tracebox to utilize the webapp - but that is unavailable on Windows. 

I am just looking to configure so I can capture locally and upload the tracefiles to the webapp. 

S Ashwin Balaji

unread,
Dec 11, 2025, 2:29:32 PM12/11/25
to Perfetto Development - www.perfetto.dev
So most likely there is a selinux issue, if you run logcat at the same time you will find a log like:

12-11 19:20:58.908 20757 20757 W perfetto: type=1400 audit(0.0:16): avc:  denied  { read } for  path="/data/local/tmp/trace_config.txt" dev="dm-51" ino=19127 scontext=u:r:perfetto:s0 tcontext=u:object_r:shell_data_file:s0 tclass=file permissive=0


Try pushing the config to /data/misc/perfetto-configs/ and then run the command

adb push config.txt /data/misc/perfetto-configs/
adb shell 'perfetto --txt -c - -o /data/misc/perfetto-traces/trace < /data/misc/perfetto-configs/config.txt'

S Ashwin Balaji

unread,
Dec 11, 2025, 2:35:32 PM12/11/25
to Perfetto Development - www.perfetto.dev

Sorry forgot sharing, for more details please refer to our documentation at: https://perfetto.dev/docs/learning-more/android

Richard Ayala

unread,
Dec 11, 2025, 3:04:42 PM12/11/25
to Perfetto Development - www.perfetto.dev
Thank you I appear unblocked now appreciate it 🤝

Richard Ayala

unread,
Dec 12, 2025, 11:11:32 AM12/12/25
to Perfetto Development - www.perfetto.dev
After you unblocked me yesterday I had no problem using perfetto without the config file - I am now trying to utilize with the config file attached in the quickstart guide: https://android.googlesource.com/platform/external/perfetto/+/e74213b02b99a05d2703a41d5543dffa45996d87/docs/quickstart/android-tracing.md

adb shell perfetto \
  -c - --txt \
  -o /data/misc/perfetto-traces/trace \
<<EOF
duration_ms: 10000

buffers: {
    size_kb: 8960
    fill_policy: DISCARD
}
buffers: {
    size_kb: 1280
    fill_policy: DISCARD
}
data_sources: {
    config {
        name: "linux.ftrace"
        ftrace_config {
            ftrace_events: "sched/sched_switch"
            ftrace_events: "power/suspend_resume"
            ftrace_events: "sched/sched_process_exit"
            ftrace_events: "sched/sched_process_free"
            ftrace_events: "task/task_newtask"
            ftrace_events: "task/task_rename"
            ftrace_events: "ftrace/print"
            atrace_categories: "gfx"
            atrace_categories: "view"
            atrace_categories: "webview"
            atrace_categories: "dalvik"
            atrace_categories: "power"
        }
    }
}
data_sources: {
    config {
        name: "linux.process_stats"
        target_buffer: 1
        process_stats_config {
            scan_all_processes_on_start: true
        }
    }
}

EOF

It is pushed correctly but when I try to use it: adb shell perfetto -c /data/misc/perfetto-configs/trace_config.txt --txt -o /data/misc/perfetto-traces/trace

The console returns the following error: 

/data/misc/perfetto-configs/trace_config.txt:1:0 error: No field named "adb" in proto TraceConfig
adb shell perfetto \
~~
[182.190] pbtxt_to_pb.cc:670      Unexpected char \ (errno: 0, Success)

S Ashwin Balaji

unread,
Dec 12, 2025, 11:27:40 AM12/12/25
to Perfetto Development - www.perfetto.dev
Hi

the adb line there is running the command, not part of config, you can find more details in https://perfetto.dev/docs/concepts/config.

Plese remove:

adb shell perfetto \
  -c - --txt \
  -o /data/misc/perfetto-traces/trace \
<<EOF

config.txt content start:
config.txt content end

Richard Ayala

unread,
Jan 5, 2026, 9:34:23 AM (5 days ago) Jan 5
to Perfetto Development - www.perfetto.dev
Thank you again. 

I'm running on a Windows machine so setup was a bit trickier than anticipated. 

I have everything running now and installed the python Trace Processor: https://perfetto.dev/docs/analysis/trace-processor-python

// spec.textproto metric_template_spec { id_prefix: "memory_per_process" dimensions: "process_name" value_column_specs: { name: "min_rss_and_swap" unit: BYTES polarity: LOWER_IS_BETTER } value_column_specs: { name: "max_rss_and_swap" unit: BYTES polarity: LOWER_IS_BETTER } value_column_specs: { name: "avg_rss_and_swap" unit: BYTES polarity: LOWER_IS_BETTER } query: { table: { table_name: "memory_rss_and_swap_per_process" } referenced_modules: "linux.memory.process" group_by: { column_names: "process_name" aggregates: { column_name: "rss_and_swap" op: MIN result_column_name: "min_rss_and_swap" } aggregates: { column_name: "rss_and_swap" op: MAX result_column_name: "max_rss_and_swap" } aggregates: { column_name: "rss_and_swap" op: DURATION_WEIGHTED_MEAN result_column_name: "avg_rss_and_swap" } } } }

I can run the following spec with this script: 

from perfetto.trace_processor import TraceProcessor with open('spec.textproto', 'r') as f: spec_text = f.read() with TraceProcessor(trace='my_trace.pftrace') as tp: summary = tp.trace_summary( specs=[spec_text], metric_ids=[ "memory_per_process_min_rss_and_swap", "memory_per_process_max_rss_and_swap", "memory_per_process_avg_rss_and_swap", ] ) print(summary)
How do I configure spec.textproto to return the metrics for the following fields: 

freq, membus, load, memory, thermal, sched, and sched_switch 

I just need high level metrics to compare to over a longer period of time. 

S Ashwin Balaji

unread,
Jan 6, 2026, 5:17:33 PM (4 days ago) Jan 6
to Richard Ayala, Perfetto Development - www.perfetto.dev
Hi Richard

To extract high-level metrics for the fields you mentioned, you can use several tables available in the Perfetto Standard Library. Please refer to the Standard Library documentation (https://perfetto.dev/docs/analysis/stdlib-docs) for a full list of modules and the Trace Summary guide (https://perfetto.dev/docs/analysis/trace-summary) for details on constructing textprotos.

The table below maps your requested fields to suitable modules and tables. Please note that these are for reference; exact queries will depend on your specific use case, so you may need to consult the documentation to identify the optimal ones.

FieldModuleTable/View
freqlinux.cpu.frequencycpu_frequency_counters
membusandroid.dvfsandroid_dvfs_counters
loadlinux.cpu.utilization.systemcpu_utilization_per_second
memoryandroid.memory.processmemory_rss_and_swap_per_process
thermalpreludeftrace_event (we don't have a generic thermal table)
schedpreludesched


So your spec.textproto might look like (again just for reference):

metric_template_spec {
id_prefix: "cpu_freq"
dimensions: "cpu"
value_columns: "avg_freq_khz"
query {
table { table_name: "cpu_frequency_counters" }
referenced_modules: "linux.cpu.frequency"
group_by {
column_names: "cpu"
aggregates {
column_name: "freq"
op: DURATION_WEIGHTED_MEAN
result_column_name: "avg_freq_khz"
}
}
}
}

metric_template_spec {
id_prefix: "membus"
dimensions: "name"
value_columns: "avg_freq_khz"
query {
table { table_name: "android_dvfs_counters" }
referenced_modules: "android.dvfs"
filters { column_name: "name" op: GLOB string_rhs: "*mif Frequency" }
group_by {
column_names: "name"
aggregates {
column_name: "value"
op: DURATION_WEIGHTED_MEAN
result_column_name: "avg_freq_khz"
}
}
}
}

metric_spec {
id: "cpu_load"
value: "avg_utilization_pct"
unit: PERCENTAGE
query {
table { table_name: "cpu_utilization_per_second" }
referenced_modules: "linux.cpu.utilization.system"
group_by {
aggregates {
column_name: "utilization"
op: MEAN
result_column_name: "avg_utilization_pct"
}
}
}
}

metric_template_spec {
id_prefix: "thermal"
dimensions: "sensor"
value_columns: "avg_temp"
query {
sql {
sql: "SELECT EXTRACT_ARG(arg_set_id, 'thermal_zone') as sensor, ts, EXTRACT_ARG(arg_set_id, 'temp') as temp FROM ftrace_event WHERE name = 'thermal_temperature'"
}
group_by {
column_names: "sensor"
aggregates {
column_name: "temp"
op: MEAN
result_column_name: "avg_temp"
}
}
}
}

metric_spec {
id: "context_switches"
value: "total_count"
unit: COUNT
query {
table { table_name: "sched" }
group_by {
aggregates {
op: COUNT
result_column_name: "total_count"
}
}
}
}

and plug in the metric_ids in your python script:

from perfetto.trace_processor import TraceProcessor

with open('spec.textproto''r'as f:
spec_text = f.read()
  
with TraceProcessor(trace='example_android_trace_15s') as tp:

summary = tp.trace_summary(
specs=[spec_text],
metric_ids=[
"cpu_freq_avg_freq_khz",
"membus_avg_freq_khz",
"cpu_load",
"thermal_avg_temp",
"context_switches"
]
)
print(summary)


--
You received this message because you are subscribed to the Google Groups "Perfetto Development - www.perfetto.dev" group.
To unsubscribe from this group and stop receiving emails from it, send an email to perfetto-dev...@googlegroups.com.
To view this discussion visit https://groups.google.com/d/msgid/perfetto-dev/0f92458c-afb1-4a2c-b821-5e22c8ebd45en%40googlegroups.com.


--
Thanks & Regards
S Ashwin Balaji

Richard Ayala

unread,
Jan 6, 2026, 5:33:35 PM (4 days ago) Jan 6
to Perfetto Development - www.perfetto.dev
Ashwin thank you again. 

If I wanted to further explore Fields/Modules/Tables. 

Is there a reference sheet somewhere to map spec.textproto correctly? 

I was having a difficult time navigating: https://perfetto.dev/docs/analysis/stdlib-docs and https://perfetto.dev/docs/analysis/trace-summary

S Ashwin Balaji

unread,
Jan 7, 2026, 9:41:35 AM (3 days ago) Jan 7
to Richard Ayala, Perfetto Development - www.perfetto.dev
Sorry, I'm afraid there isn't a single reference sheet, and intentionally so: the trace summary is designed as a flexible layer built on top of our existing SQL tables and functions. Its purpose is to decouple the underlying data computation from how those metrics are aggregated and reported.

I would recommend you follow the steps as:
1) Use the Standard Library as your Data Dictionary: Search it to identify the specific tables that contain the raw data you need (e.g., identifying cpu_frequency_counters for frequency metrics). We have tried to split the stdlib doc into different sections and tables and also have a filter option on top to help you a bit. On the trace you care about, you can experiment by running sql queries first to see and validate.
2) Define your aggregation in the spec.textproto: Once you have identified the source table, use the trace summary query to define how that data should be aggregated


S Ashwin Balaji

unread,
Jan 7, 2026, 9:45:22 AM (3 days ago) Jan 7
to Richard Ayala, Perfetto Development - www.perfetto.dev
Reply all
Reply to author
Forward
0 new messages