PERFETTO(1)
π PERFETTO(1) π β the perfetto girlies' guide to capturing traces
okay so bestie, welcome to the perfetto manual page (that's the General Commands Manual one, mwah). pull up a chair, grab a strawberry π, and let's learn how to capture traces together. no cap, this one's a banger.
β¨ NAME β¨
perfetto β capture traces π
πΈ DESCRIPTION πΈ
this section is literally all about how to use the perfetto commandline binary to capture traces. all the examples are given in terms of an Android device connected over ADB, iykyk.
so perfetto has two modes for configuring the tracing session (aka what you're collecting and how you're collecting it):
- lightweight mode β every config option gets supplied as commandline flags, but the available data sources are restricted to
ftraceandatrace. this mode is similar tosystrace. cute and quick π - normal mode β the configuration is specified in a protocol buffer. this allows for full customisation of collected traces. main character energy fr fr π
π GENERAL OPTIONS π
the following table lists all the available options when you're using perfetto in either mode. slay.
-d,--backgroundβperfettoimmediately exits the command-line interface and continues recording your trace in background. bye bestie, still recording tho π«Ά-D,--background-waitβ like--background, but it waits (up to 30s) for all data sources to be started before exiting. patient queen β¨--notify-fd FDβ like--background-wait, but instead of daemonizing and waiting before exiting, it writes one status byte and closes the given file descriptor. writes0on success, non-zero on timeout/error. not supported on Windows. π-o,--out OUT_FILEβ specifies the desired path to the output trace file, or-for stdout.perfettowrites the output to the file described in the flags above. the output format compiles with the format defined in AOSPtrace.proto. π--no-clobberβ do not overwrite an existing output file. protect the babies π--clone TSIDβ creates a read-only clone of an existing tracing session identified by session id (see--query). π§¬--clone-by-name NAMEβ creates a read-only clone of an existing tracing session identified byunique_session_name.--clone-for-bugreportβ can only be used with--cloneor--clone-by-name. disablestrace_filteron the cloned session.--add-note key[=value]β adds a user note to the trace config. if=valueis omitted,valueis an empty string. βοΈ--versionβ prints theperfettoversion string and exits.--dropbox TAGβ deprecated. uploads your trace via theDropBoxManagerAPI using the tag you specify. Android only. use--uploadinstead. (we don't gatekeep, we just move on π )--uploadβ uploads trace output to Android framework reporting paths configured inTraceConfig(android_report_config). Android only.--alert-id IDβ statsd metadata. ID of the alert that triggered this trace. π¨--config-id IDβ statsd metadata. ID of the triggering config.--config-uid UIDβ statsd metadata. UID of app which registered the triggering config.--subscription-id IDβ statsd metadata. ID of the subscription that triggered this trace.--save-for-bugreportβ if a trace withbugreport_score > 0is running, it saves it into a file and outputs the path when done.--save-all-for-bugreportβ clones all eligible bugreport sessions and saves them into bugreport output files. the whole squad, collected π--no-guardrailsβ disables protections against excessive resource usage when using--upload(testing only). β οΈ--reset-guardrailsβ compatibility option. Guardrails no longer exist inperfetto_cmd; this option remains for backwards compatibility.--queryβ queries the service state and prints it as human-readable text. π--longβ expands some fields in--queryoutput (for example category lists). can only be used with--query.--query-rawβ similar to--query, but prints raw proto-encoded bytes oftracing_service_state.proto.--detach KEYβ detach from tracing session using the given key. π¦--attach KEYβ re-attach to a detached tracing session using the given key.--stopβ stop tracing once re-attached. supported only with--attach.--is_detached KEYβ checks whether the session can be re-attached. exit code semantics:0yes,2no,1error. (yes bestie, three whole numbers, memorize them π )-h,--helpβ prints out help text for theperfettotool. when in doubt, ask for help, that's growth π
π SIMPLE MODE π
for ease of use, the perfetto command includes support for a subset of configurations via command line arguments. on-device, these configurations behave equivalently to the same configurations provided by a CONFIG_FILE (see below). love that for us.
the general syntax for using perfetto in simple mode is as follows:
adb shell perfetto [ --time TIMESPEC ] [ --buffer SIZE ] [ --size SIZE ]
[ --app APP_NAME ]
[ ATRACE_CAT | FTRACE_GROUP/FTRACE_NAME]...
the following table lists the available options when you're using perfetto in simple mode. πΈ
-t,--time TIME[s|m|h]β specifies the trace duration in seconds, minutes, or hours. for example,--time 1mspecifies a trace duration of 1 minute. the default duration is 10 seconds. β°-b,--buffer SIZE[mb|gb]β specifies the ring buffer size in megabytes (mb) or gigabytes (gb). the default parameter is--buffer 32mb. π«-s,--size SIZE[mb|gb]β specifies the max file size in megabytes (mb) or gigabytes (gb). by defaultperfettouses only in-memory ring-buffer.-a,--app APP_NAMEβ specifies an Android app name for atrace app-level tracing. π±
this is followed by a list of event specifiers:
ATRACE_CATβ specifies the atrace categories you want to record a trace for. for example, the following command traces Window Manager using atrace:adb shell perfetto --out FILE wm. to record other categories, see the list of atrace categories. note: available categories are Android version dependent. π§FTRACE_GROUP/FTRACE_NAMEβ specifies the ftrace events you want to record a trace for. for example, the following command tracessched/sched_switchevents:adb shell perfetto --out FILE sched/sched_switch. π₯
π NORMAL MODE π
the general syntax for using perfetto in normal mode is as follows:
adb shell perfetto [ --txt ] --config CONFIG_FILE
the following table lists the available options when you're using perfetto in normal mode. β¨
-c,--config CONFIG_FILEβ specifies the path to a configuration file. in normal mode, some configurations may be encoded in a configuration protocol buffer. this file must comply with the protocol buffer schema defined in AOSPtrace_config.proto. you select and configure the data sources using theDataSourceConfigmember of theTraceConfig, as defined in AOSPdata_source_config.proto. use-to read config bytes from stdin. π--txtβ instructsperfettoto parse the config file aspbtxt. this flag is not a stable API and is not recommended for production. β οΈ
ngl the --txt thing is giving "not for prod" vibes. treat it accordingly bestie π
and that's the whole page!! ty for reading the PERFETTO(1) manual, you ate that fr fr ππ β¨
~ fin (the General Commands Manual version, PERFETTO(1)) ~
π¦ where this page comes from
- ubuntu stonking: perfetto 56.0-1 Β· Apache-2.0
- π girlified by deepseek-ai/DeepSeek-V4.1-Flash on : a language model's rewrite of the original, under its terms