Perfetto log 与解析

2022-05-13 21:12:53 浏览数 (1)

从抓Perfetto log 到log的解析,Perfetto 与systrace log有很大的不同。Perfetto把很多系统级的log如单个进程的memory/GPU ion/adj/native/java memory debug/proc/stat /logcat/CPU freq/CPU 调度/CPU C stat/power 电压/电池的使用/syscall 等merge 在一起,一并在UI 上显示出来,可以观察到引起系统性能的各个因数。不夸张的说,如果能看懂Perfetto 在抓log界面里面设置每一项是什么意思,能抓到哪些log,那么你对性能的调试可以算已经入门,否则,需要进一步学习。

从Perfetto UI 抓取 Perfetto log

Buffer size /duration

CPU

GPU

Power:

Memroy:

也可以在手机上手动执行抓perfetto log

adb shell perfetto

-c - --txt

-o/data/misc/perfetto-traces/trace

<<EOF

buffers: {

size_kb: 63488

fill_policy:DISCARD

}

buffers: {

size_kb: 2048

fill_policy:DISCARD

}

data_sources: {

config {

name:"android.gpu.memory"

}

}

data_sources: {

config {

name:"android.power"

android_power_config {

battery_poll_ms: 1000

battery_counters: BATTERY_COUNTER_CAPACITY_PERCENT

battery_counters: BATTERY_COUNTER_CHARGE

battery_counters: BATTERY_COUNTER_CURRENT

collect_power_rails: true

}

}

}

data_sources: {

config {

name:"linux.process_stats"

target_buffer:1

process_stats_config {

scan_all_processes_on_start: true

proc_stats_poll_ms: 1000

}

}

}

data_sources: {

config {

name:"android.log"

android_log_config {

}

}

}

data_sources: {

config {

name:"linux.sys_stats"

sys_stats_config {

meminfo_period_ms: 1000

meminfo_counters: MEMINFO_MEM_TOTAL

meminfo_counters: MEMINFO_MEM_FREE

meminfo_counters: MEMINFO_MEM_AVAILABLE

meminfo_counters: MEMINFO_BUFFERS

meminfo_counters: MEMINFO_CACHED

meminfo_counters: MEMINFO_SWAP_CACHED

meminfo_counters: MEMINFO_ACTIVE

meminfo_counters: MEMINFO_INACTIVE

meminfo_counters: MEMINFO_ACTIVE_ANON

meminfo_counters: MEMINFO_INACTIVE_ANON

meminfo_counters: MEMINFO_ACTIVE_FILE

meminfo_counters: MEMINFO_INACTIVE_FILE

meminfo_counters: MEMINFO_UNEVICTABLE

meminfo_counters: MEMINFO_MLOCKED

meminfo_counters: MEMINFO_SWAP_TOTAL

meminfo_counters: MEMINFO_SWAP_FREE

meminfo_counters: MEMINFO_DIRTY

meminfo_counters: MEMINFO_WRITEBACK

meminfo_counters: MEMINFO_ANON_PAGES

meminfo_counters: MEMINFO_MAPPED

meminfo_counters: MEMINFO_SHMEM

meminfo_counters: MEMINFO_SLAB

meminfo_counters: MEMINFO_SLAB_RECLAIMABLE

meminfo_counters: MEMINFO_SLAB_UNRECLAIMABLE

meminfo_counters: MEMINFO_KERNEL_STACK

meminfo_counters: MEMINFO_PAGE_TABLES

meminfo_counters: MEMINFO_COMMIT_LIMIT

meminfo_counters: MEMINFO_COMMITED_AS

meminfo_counters: MEMINFO_VMALLOC_TOTAL

meminfo_counters: MEMINFO_VMALLOC_USED

meminfo_counters: MEMINFO_VMALLOC_CHUNK

meminfo_counters: MEMINFO_CMA_TOTAL

meminfo_counters: MEMINFO_CMA_FREE

vmstat_period_ms: 1000

vmstat_counters: VMSTAT_NR_FREE_PAGES

vmstat_counters: VMSTAT_NR_ALLOC_BATCH

vmstat_counters: VMSTAT_NR_INACTIVE_ANON

vmstat_counters: VMSTAT_NR_ACTIVE_ANON

vmstat_counters: VMSTAT_NR_INACTIVE_FILE

vmstat_counters: VMSTAT_NR_ACTIVE_FILE

vmstat_counters: VMSTAT_NR_UNEVICTABLE

vmstat_counters: VMSTAT_NR_MLOCK

vmstat_counters: VMSTAT_NR_ANON_PAGES

vmstat_counters: VMSTAT_NR_MAPPED

vmstat_counters: VMSTAT_NR_FILE_PAGES

vmstat_counters: VMSTAT_NR_DIRTY

vmstat_counters: VMSTAT_NR_WRITEBACK

vmstat_counters:VMSTAT_NR_SLAB_RECLAIMABLE

vmstat_counters: VMSTAT_NR_SLAB_UNRECLAIMABLE

vmstat_counters: VMSTAT_NR_PAGE_TABLE_PAGES

vmstat_counters: VMSTAT_NR_KERNEL_STACK

vmstat_counters: VMSTAT_NR_OVERHEAD

vmstat_counters: VMSTAT_NR_UNSTABLE

vmstat_counters: VMSTAT_NR_BOUNCE

vmstat_counters: VMSTAT_NR_VMSCAN_WRITE

vmstat_counters: VMSTAT_NR_VMSCAN_IMMEDIATE_RECLAIM

vmstat_counters: VMSTAT_NR_WRITEBACK_TEMP

vmstat_counters: VMSTAT_NR_ISOLATED_ANON

vmstat_counters: VMSTAT_NR_ISOLATED_FILE

vmstat_counters: VMSTAT_NR_SHMEM

vmstat_counters: VMSTAT_NR_DIRTIED

vmstat_counters: VMSTAT_NR_WRITTEN

vmstat_counters: VMSTAT_NR_PAGES_SCANNED

vmstat_counters: VMSTAT_WORKINGSET_REFAULT

vmstat_counters: VMSTAT_WORKINGSET_ACTIVATE

vmstat_counters: VMSTAT_WORKINGSET_NODERECLAIM

vmstat_counters: VMSTAT_NR_ANON_TRANSPARENT_HUGEPAGES

vmstat_counters: VMSTAT_NR_FREE_CMA

vmstat_counters: VMSTAT_NR_SWAPCACHE

vmstat_counters: VMSTAT_NR_DIRTY_THRESHOLD

vmstat_counters: VMSTAT_NR_DIRTY_BACKGROUND_THRESHOLD

vmstat_counters: VMSTAT_PGPGIN

vmstat_counters: VMSTAT_PGPGOUT

vmstat_counters: VMSTAT_PGPGOUTCLEAN

vmstat_counters: VMSTAT_PSWPIN

vmstat_counters: VMSTAT_PSWPOUT

vmstat_counters: VMSTAT_PGALLOC_DMA

vmstat_counters: VMSTAT_PGALLOC_NORMAL

vmstat_counters: VMSTAT_PGALLOC_MOVABLE

vmstat_counters: VMSTAT_PGFREE

vmstat_counters: VMSTAT_PGACTIVATE

vmstat_counters: VMSTAT_PGDEACTIVATE

vmstat_counters: VMSTAT_PGFAULT

vmstat_counters: VMSTAT_PGMAJFAULT

vmstat_counters: VMSTAT_PGREFILL_DMA

vmstat_counters: VMSTAT_PGREFILL_NORMAL

vmstat_counters: VMSTAT_PGREFILL_MOVABLE

vmstat_counters: VMSTAT_PGSTEAL_KSWAPD_DMA

vmstat_counters: VMSTAT_PGSTEAL_KSWAPD_NORMAL

vmstat_counters: VMSTAT_PGSTEAL_KSWAPD_MOVABLE

vmstat_counters: VMSTAT_PGSTEAL_DIRECT_DMA

vmstat_counters: VMSTAT_PGSTEAL_DIRECT_NORMAL

vmstat_counters: VMSTAT_PGSTEAL_DIRECT_MOVABLE

vmstat_counters: VMSTAT_PGSCAN_KSWAPD_DMA

vmstat_counters: VMSTAT_PGSCAN_KSWAPD_NORMAL

vmstat_counters: VMSTAT_PGSCAN_KSWAPD_MOVABLE

vmstat_counters: VMSTAT_PGSCAN_DIRECT_DMA

vmstat_counters: VMSTAT_PGSCAN_DIRECT_NORMAL

vmstat_counters: VMSTAT_PGSCAN_DIRECT_MOVABLE

vmstat_counters: VMSTAT_PGSCAN_DIRECT_THROTTLE

vmstat_counters: VMSTAT_PGINODESTEAL

vmstat_counters: VMSTAT_SLABS_SCANNED

vmstat_counters: VMSTAT_KSWAPD_INODESTEAL

vmstat_counters:VMSTAT_KSWAPD_LOW_WMARK_HIT_QUICKLY

vmstat_counters: VMSTAT_KSWAPD_HIGH_WMARK_HIT_QUICKLY

vmstat_counters: VMSTAT_PAGEOUTRUN

vmstat_counters: VMSTAT_ALLOCSTALL

vmstat_counters: VMSTAT_PGROTATED

vmstat_counters:VMSTAT_DROP_PAGECACHE

vmstat_counters: VMSTAT_DROP_SLAB

vmstat_counters: VMSTAT_PGMIGRATE_SUCCESS

vmstat_counters: VMSTAT_PGMIGRATE_FAIL

vmstat_counters: VMSTAT_COMPACT_MIGRATE_SCANNED

vmstat_counters: VMSTAT_COMPACT_FREE_SCANNED

vmstat_counters: VMSTAT_COMPACT_ISOLATED

vmstat_counters: VMSTAT_COMPACT_STALL

vmstat_counters: VMSTAT_COMPACT_FAIL

vmstat_counters: VMSTAT_COMPACT_SUCCESS

vmstat_counters: VMSTAT_COMPACT_DAEMON_WAKE

vmstat_counters: VMSTAT_UNEVICTABLE_PGS_CULLED

vmstat_counters: VMSTAT_UNEVICTABLE_PGS_SCANNED

vmstat_counters: VMSTAT_UNEVICTABLE_PGS_RESCUED

vmstat_counters:VMSTAT_UNEVICTABLE_PGS_MLOCKED

vmstat_counters: VMSTAT_UNEVICTABLE_PGS_MUNLOCKED

vmstat_counters: VMSTAT_UNEVICTABLE_PGS_CLEARED

vmstat_counters: VMSTAT_UNEVICTABLE_PGS_STRANDED

vmstat_counters: VMSTAT_NR_ZSPAGES

vmstat_counters: VMSTAT_NR_ION_HEAP

vmstat_counters: VMSTAT_NR_GPU_HEAP

vmstat_counters: VMSTAT_ALLOCSTALL_DMA

vmstat_counters:VMSTAT_ALLOCSTALL_MOVABLE

vmstat_counters: VMSTAT_ALLOCSTALL_NORMAL

vmstat_counters: VMSTAT_COMPACT_DAEMON_FREE_SCANNED

vmstat_counters: VMSTAT_COMPACT_DAEMON_MIGRATE_SCANNED

vmstat_counters:VMSTAT_NR_FASTRPC

vmstat_counters: VMSTAT_NR_INDIRECTLY_RECLAIMABLE

vmstat_counters: VMSTAT_NR_ION_HEAP_POOL

vmstat_counters: VMSTAT_NR_KERNEL_MISC_RECLAIMABLE

vmstat_counters: VMSTAT_NR_SHADOW_CALL_STACK_BYTES

vmstat_counters: VMSTAT_NR_SHMEM_HUGEPAGES

vmstat_counters: VMSTAT_NR_SHMEM_PMDMAPPED

vmstat_counters: VMSTAT_NR_UNRECLAIMABLE_PAGES

vmstat_counters: VMSTAT_NR_ZONE_ACTIVE_ANON

vmstat_counters:VMSTAT_NR_ZONE_ACTIVE_FILE

vmstat_counters: VMSTAT_NR_ZONE_INACTIVE_ANON

vmstat_counters: VMSTAT_NR_ZONE_INACTIVE_FILE

vmstat_counters: VMSTAT_NR_ZONE_UNEVICTABLE

vmstat_counters: VMSTAT_NR_ZONE_WRITE_PENDING

vmstat_counters: VMSTAT_OOM_KILL

vmstat_counters: VMSTAT_PGLAZYFREE

vmstat_counters: VMSTAT_PGLAZYFREED

vmstat_counters: VMSTAT_PGREFILL

vmstat_counters: VMSTAT_PGSCAN_DIRECT

vmstat_counters: VMSTAT_PGSCAN_KSWAPD

vmstat_counters: VMSTAT_PGSKIP_DMA

vmstat_counters: VMSTAT_PGSKIP_MOVABLE

vmstat_counters: VMSTAT_PGSKIP_NORMAL

vmstat_counters: VMSTAT_PGSTEAL_DIRECT

vmstat_counters: VMSTAT_PGSTEAL_KSWAPD

vmstat_counters: VMSTAT_SWAP_RA

vmstat_counters: VMSTAT_SWAP_RA_HIT

stat_period_ms: 1000

stat_counters: STAT_CPU_TIMES

stat_counters: STAT_FORK_COUNT

}

}

}

data_sources: {

config {

name:"android.heapprofd"

target_buffer:0

heapprofd_config {

sampling_interval_bytes: 4096

shmem_size_bytes: 8388608

block_client: true

}

}

}

data_sources: {

config {

name:"android.java_hprof"

target_buffer:0

java_hprof_config {

}

}

}

data_sources: {

config {

name:"linux.ftrace"

ftrace_config{

ftrace_events: "binder/*"

ftrace_events: "block/*"

ftrace_events: "clk/*"

ftrace_events: "ext4/*"

ftrace_events: "f2fs/*"

ftrace_events:"i2c/*"

ftrace_events: "irq/*"

ftrace_events: "kmem/*"

ftrace_events: "memory_bus/*"

ftrace_events: "mmc/*"

ftrace_events: "oom/*"

ftrace_events: "power/*"

ftrace_events:"regulator/*"

ftrace_events: "sched/*"

ftrace_events: "sync/*"

ftrace_events: "task/*"

ftrace_events: "vmscan/*"

ftrace_events: "fastrpc/*"

ftrace_events: "sched/sched_switch"

ftrace_events:"power/suspend_resume"

ftrace_events: "sched/sched_wakeup"

ftrace_events: "sched/sched_wakeup_new"

ftrace_events: "sched/sched_waking"

ftrace_events: "power/cpu_frequency"

ftrace_events: "power/cpu_idle"

ftrace_events: "power/gpu_frequency"

ftrace_events: "gpu_mem/gpu_mem_total"

ftrace_events: "raw_syscalls/sys_enter"

ftrace_events:"raw_syscalls/sys_exit"

ftrace_events: "sched/sched_process_exit"

ftrace_events: "sched/sched_process_free"

ftrace_events: "task/task_newtask"

ftrace_events: "task/task_rename"

ftrace_events:"regulator/regulator_set_voltage"

ftrace_events: "regulator/regulator_set_voltage_complete"

ftrace_events: "power/clock_enable"

ftrace_events: "power/clock_disable"

ftrace_events: "power/clock_set_rate"

ftrace_events: "mm_event/mm_event_record"

ftrace_events: "kmem/rss_stat"

ftrace_events: "ion/ion_stat"

ftrace_events: "kmem/ion_heap_grow"

ftrace_events: "kmem/ion_heap_shrink"

ftrace_events:"lowmemorykiller/lowmemory_kill"

ftrace_events: "oom/oom_score_adj_update"

ftrace_events: "ftrace/print"

atrace_categories: "gfx"

atrace_categories: "input"

atrace_categories: "view"

atrace_categories: "webview"

atrace_categories: "wm"

atrace_categories: "am"

atrace_categories: "sm"

atrace_categories: "audio"

atrace_categories: "video"

atrace_categories: "camera"

atrace_categories: "hal"

atrace_categories: "res"

atrace_categories: "dalvik"

atrace_categories: "rs"

atrace_categories: "bionic"

atrace_categories: "power"

atrace_categories: "pm"

atrace_categories: "ss"

atrace_categories: "database"

atrace_categories: "network"

atrace_categories: "adb"

atrace_categories:"vibrator"

atrace_categories: "aidl"

atrace_categories: "nnapi"

atrace_categories: "rro"

atrace_categories: "binder_driver"

atrace_categories: "binder_lock"

atrace_apps:"lmkd"

buffer_size_kb: 2048

drain_period_ms: 250

}

}

}

duration_ms: 10000

EOF

Perfetto log 解析

0 人点赞