本讲是Android Camera性能分析专题的第34讲,我们介绍Perfetto 分析CPU 频率。
更多资源:
资源 | 描述 |
---|---|
在线课程 | 极客笔记在线课程 |
知识星球 | 星球名称:深入浅出Android Camera 星球ID: 17296815 |
极客笔记圈 |
Perfetto CPU Frequency分析需要打开的Config
需要打开Scheduling events Trace Config + CPU frequency and idle states。
data_sources: {
config {
name: "linux.process_stats"
target_buffer: 1
process_stats_config {
scan_all_processes_on_start: true
}
}
}
data_sources: {
config {
name: "linux.ftrace"
ftrace_config {
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: "sched/sched_process_exit"
ftrace_events: "sched/sched_process_free"
ftrace_events: "task/task_newtask"
ftrace_events: "task/task_rename"
buffer_size_kb: 2048
drain_period_ms: 250
}
}
}
读取Ftrace的Trace config:
data_sources: {
config {
name: "linux.ftrace"
ftrace_config {
ftrace_events: "power/cpu_frequency"
ftrace_events: "power/cpu_idle"
ftrace_events: "power/suspend_resume"
}
}
}
读取/sys/devices/system/cpu/cpu*/cpufreq/cpuinfo_cur_freq
data_sources: {
config {
name: "linux.sys_stats"
sys_stats_config {
cpufreq_period_ms: 1000
}
}
}
Perfetto 查看每个CPU的Frequency变化情况
Perfetto上可以查看每个CPU Frequency的变量情况。
注意:在许多情况下,CPU的频率在几秒钟内不会发生变化,如果录制trace的过程中frequency一直没有变化,则不会显示frequency这几行。
Perfetto 查看某段slice跑在哪个CPU以及频率
Perfetto 查看某段slice跑在哪个CPU以及频率:
点击slice,可以看到Running on CPU 4,因此该Task被调度到CPU 4上运行:
跳到CPU区域,能看到当前CPU4的Frequency为1500000MHz
Perfetto 查看各CPU支持的所有频率
打开linux.system_info data source:
data_sources {
config {
name: "linux.system_info"
}
}
在Perfetto中执行如下SQL语句查询各CPU的Frequency列表
select * from cpu_freq
输出: