性能分析-Perfetto

AMLogic

adb shell cat /sys/bus/cpu/devices/cpu0/cpufreq/cpuinfo_cur_freq

参考文档

Android官网

https://developer.android.google.cn/topic/performance/tracing/command-line

https://developer.android.google.cn/studio/command-line/perfetto

Perfetto官网

https://perfetto.dev/docs/data-sources/native-heap-profiler

Native heap profiler - Perfetto Tracing Docs

其他

https://blog.csdn.net/sinat_20059415/article/details/106305944

adb shell setprop persist.traced.enable 1

如下,来自https://perfetto.dev/docs/quickstart/android-tracing

1. Using the on-device /system/bin/perfetto command

adb shell perfetto -o /data/misc/perfetto-traces/trace_file.perfetto-trace -t 20s \
sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory

adb pull data/misc/perfetto-traces/trace_file.perfetto-trace

2. Using the helper script: using the tools/record_android_trace script to record traces from the command line

~$curl -O https://raw.githubusercontent.com/google/perfetto/master/tools/record_android_trace

~$chmod u+x record_android_trace

~$./record_android_trace -o trace_file.perfetto-trace -t 10s -b 32mb \

sched freq idle am wm gfx view binder_driver hal dalvik camera input res memory

在函数开始位置添加ATRACE_CALL()后,在systrace里可以跟踪到调用这个函数的线程。

在函数里添加ATRACE_ASYNC_BEGIN后,在systrace里可以单独列出当前标识。

status_t Camera3Device::RequestThread::prepareHalRequests() {

        ATRACE_ASYNC_BEGIN("still capture", mNextRequests[i].halRequest.frame_number);

void Camera3Device::removeInFlightRequestIfReadyLocked(int idx) {

        ATRACE_ASYNC_END("still capture", frameNumber);

pertetto_config.txt内容如下:

buffers: {    
    size_kb: 63488    
    fill_policy: DISCARD    
}    
buffers: {    
    size_kb: 2048    
    fill_policy: DISCARD    
}    
data_sources: {    
    config {    
        name: "linux.sys_stats"    
        sys_stats_config {    
            vmstat_period_ms: 1000    
            vmstat_counters: VMSTAT_ALLOCSTALL    
        }    
    }    
}    
data_sources: {    
    config {    
        name: "android.heapprofd"    
        target_buffer: 0    
        heapprofd_config {    
            sampling_interval_bytes: 4096    
            process_cmdline: "cameraserver"    
            shmem_size_bytes: 8388608    
            block_client: true    
        }    
    }    
}    
data_sources: {    
    config {    
        name: "linux.ftrace"    
        ftrace_config {     
            ftrace_events: "power/gpu_frequency"    
            ftrace_events: "ftrace/print"    
            atrace_categories: "camera"    
        }                                                                                                                                                                                                   
    }    
}    
duration_ms: 10000

cat pertetto_config | adb shell perfetto -c - --txt -o /data/misc/perfetto-traces/trace.perfetto-trace

adb pull /data/misc/perfetto-traces/trace.perfetto-trace .

可以用perfetto分析卡顿和内存问题,尤其卡顿问题,每一帧耗时多长,每个node的耗时多长都可以清晰的看到,CPU的占用率及频率,注意APP到Framework再到HAL的buffer跳转走的是binder,通过点击binder箭头可以前后切换。另外,某个线程如果有绑核行为,通过trace也可以清晰看出来。

关于CPU的状态信息也可以通过cat命令查看,如下:

adb shell cat sys/devices/system/cpu/cpufreq/policy*/scaling_min_freq

adb shell cat sys/devices/system/cpu/cpufreq/policy*/scaling_max_freq

adb shell cat sys/class/kgsl/kgsl-3do/devfreq/min_freq

adb shell cat sys/class/kgsl/kgsl-3d0/devfreq/max_freq

adb shell cat sys/class/kgsl/kgsl-3d0/devfreq/cur_freq

adb shell cat /proc/sys/kernel/sched_boost

adb shell cat /proc/sys/kernel/sched_window_stats_policy

adb shell cat /proc/sys/kernel/sched_upmigrate

adb shell cat /proc/sys/kernel/sched_downmigrate

adb shell cat /proc/sys/devices/system/cpu/cpu*/isolate

adb shell cat /proc/sys/devices/system/cpu/cpu*/cpufreq/scaling_min_freq

pause

导致卡顿的原因,有可能是丢帧,也有可能是总帧间隔方差大或者帧率方差大导致。参考systrace,帧间隔可以重点看消费者的上升沿,如果上升沿的间隔或者帧率不对,说明HAL生产者输出的buffer有问题,需要HAL排查。

如果有丢帧可以从两个方面考虑:负载引起的资源抢占还是内存造成的内存分配慢。如果是负载引起的抢占,可以进一步确认是否是查杀策略导致的负载差异,必要时拉通系统伙伴确认,确认UI first是否生效;如果是内存引起的内存分配慢,比较模式内存占用的大小,确认boost pool是否生效,kernel log中搜boostpool。

功耗分析思路:OPPO用的ORMS,主要参数写一写。

1.排除相机外部因素:

测试手法:例如是否对准人头模型,涉及是否有美颜算法,虚化算法,人脸识别算法等。

测试环境:如iso,不同iso可能会影响单帧,多帧算法。

版本是否正确

功耗机型号,如显示屏,模组等是否有差异。

2.出图size、帧率是否符合要求。

3.feature、算法,分析测试机与对比机是否开了不同的feature,走了不同的算法。

4.各线程占用率是否符合要求。

5.CPU频率:测试机与对比机限频策略是否一致。

6.GPU频率:测试机与对比机限频策略是否一致。

Energy Aware Scheduling(EAS)

Linux调度新特性EAS_Hugo的博客-CSDN博客_eas调度

讲内存的文章

内存不能为read进不去桌面_内存与IO的交换_weixin_39662228的博客-CSDN博客

systrace分析Camera卡顿

Camera360 录像预览滞后-完整修正版

select a.callsite_id, a.ts, a.upid, a.heap_name, a.type, a.id, a.ts, f.name, f.rel_pc, m.build_id, m.name as mapping_name,
        sum(a.size) as space_size, sum(a.count) as space_count
      from heap_profile_allocation a join
           stack_profile_callsite c ON (a.callsite_id = c.id) join
           stack_profile_frame f ON (c.frame_id = f.id) join
           stack_profile_mapping m ON (f.mapping = m.id)
      group by 1, 2, 3, 4, 5, 6, 7 order by space_size desc;

下面截图来自CSDN

  • 0
    点赞
  • 3
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值