Compare commits

..

No commits in common. "2690dc833d4e30ccbbbbbc005f265a2dcf1981d8" and "c7a76019a96b6efca4b07c8130b9ed0eea800027" have entirely different histories.

3 changed files with 43 additions and 65 deletions

28
applist
View File

@ -1,17 +1,13 @@
com.UCMobile
com.taobao.taobao
com.qiyi.video
com.ss.android.ugc.aweme
com.smile.gifmaker
com.kugou.android
com.xunmeng.pinduoduo
tv.danmaku.bili
com.tencent.qqlive
com.jingdong.app.mall
com.android.camera
com.tencent.tmgp.sgame
com.tencent.tmgp.pubgmhd
com.tencent.jkchess
com.miHoYo.Yuanshen
com.tencent.KiHan
com.miHoYo.enterprise.NGHSoD
com.xingin.xhs
com.taobao.taobao
com.ss.android.article.news
com.sina.weibo
com.smile.gifmaker
air.tv.douyu.android
com.ss.android.ugc.aweme.lite
com.kuaishou.nebula
com.sup.android.superb
com.ss.android.ugc.aweme
com.taobao.idlefish
com.duowan.kiwi

View File

@ -98,5 +98,5 @@ data_sources: {
}
}
}
duration_ms: 10000
duration_ms: 20000

78
run.sh
View File

@ -1,13 +1,11 @@
#$dirput: round app start_time(ms) start_type rss(MB) pss(MB) ratio pagefault minorfaults majorfaults itlbmiss dtlbmiss cpustalled
cycle=3
WAIT=3
wait=3
clear_background=0
mthp_stat=0
cleancache=0
REBOOT=0
while getopts ":s:c:w:h:kTCR" opt
while getopts ":s:c:w:h:kT" opt
do
case $opt in
s)
@ -20,17 +18,11 @@ do
clear_background=1
;;
w)
WAIT=$OPTARG
;;
R)
REBOOT=1
wait=$OPTARG
;;
T)
mthp_stat=1
;;
C)
cleancache=1
;;
h)
echo "usage: run.sh -s sid -c cycle -w wait_seconds"
exit 1
@ -40,8 +32,6 @@ do
echo "usage: run.sh -s sid -c cycle -w wait_time [-C]"
echo "-s: specify serial id of device"
echo "-c: specify applist startup cycle"
echo "-C: drop cache before start app"
echo "-R: reboot before each cycle"
echo "-w: specify wait time after app start, before start next app, default 10 s"
echo "-k: if to kill all background apps before start app"
echo "-T: if check app's mTHP status"
@ -78,29 +68,25 @@ mkdir $dir/meminfo
mkdir $dir/simpleperf
mkdir $dir/thpmaps
echo "round app start_type start_time rss pss pagefaults minorfaults majorfaults itlbmiss dtlbmiss cpustall inc_ratio inc_total order4_ratio order4_cont nr_inc_direct_reclaim" >> $dir/result
echo "round app start_type start_time rss pss pagefaults minorfaults majorfaults itlbmiss dtlbmiss cpustall inc_ratio order4_ratio order4_cont inc_total nr_direct_reclaim" > $dir/result
for round in $(seq 1 $cycle); do
if [ $REBOOT -eq 1 ]; then
# 重启并等待重启完成
echo "rebooting"
adb reboot
sleep 30
# 重启并等待重启完成
echo "rebooting"
adb reboot
sleep 30
# 重启后等待adb
# 如果10min还未成功则判断失败
for w in $(seq 1 600); do
if [ $(adb devices | grep $ANDROID_SERIAL -c) -eq 0 ]; then
echo waiting device $w
sleep 1
continue
fi
adb root
break
done
sleep 10
fi
# 重启后等待adb
# 如果10min还未成功则判断失败
for w in $(seq 1 600); do
if [ $(adb devices | grep $ANDROID_SERIAL -c) -eq 0 ]; then
echo waiting device $w
sleep 1
continue
fi
adb root
break
done
adb root
adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/enabled > $dir/hugepages-64kB_enabled
@ -122,14 +108,6 @@ for round in $(seq 1 $cycle); do
for app in `cat applist`; do
sleep 3
if [ $clear_background -ne 0 ]; then
./clearapp.sh
fi
if [ $cleancache -ne 0 ]; then
adb shell "echo 3 > /proc/sys/vm/drop_caches"
fi
# 抓内存相关信息
adb shell free -h > $dir/system_mem/before_free-$app-$round
adb shell cat /proc/meminfo > $dir/system_mem/before_meminfo-$app-$round
@ -138,6 +116,11 @@ for round in $(seq 1 $cycle); do
adb shell cat /proc/pagetypeinfo > $dir/system_mem/before_pagetypeinfo-$app-$round
adb shell cat /proc/vmstat > $dir/system_mem/before_vmstat-$app-$round
# 开始抓simpleperf和perfetto
adb shell "simpleperf stat -e dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,page-faults,raw-stall-backend-mem,minor-faults,major-faults --app $app --duration 3 -o /data/local/tmp/simpleperf-"$app"-"$round".txt" &
adb shell "perfetto -c /data/misc/perfetto-configs/perfconf.txt --txt -o /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace" &
perfetto_pid=$!
# 获取应用activity
if [ "$app" == "com.qiyi.video" ]; then
activity="com.qiyi.video/com.qiyi.video.WelcomeActivity"
@ -162,18 +145,13 @@ for round in $(seq 1 $cycle); do
# 抓电池信息
adb shell "dumpsys battery" > $dir/battery/battery-$app-$round
# 开始抓simpleperf和perfetto
adb shell "simpleperf stat -e dTLB-loads,dTLB-load-misses,iTLB-loads,iTLB-load-misses,page-faults,raw-stall-backend-mem,minor-faults,major-faults --app $app --duration 3 -o /data/local/tmp/simpleperf-"$app"-"$round".txt" &
adb shell "perfetto -c /data/misc/perfetto-configs/perfconf.txt --txt -o /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace" &
perfetto_pid=$!
prev_alloc=$(adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_alloc)
prev_alloc_fallback=$(adb shell cat /sys/kernel/mm/transparent_hugepage/hugepages-64kB/stats/anon_fault_fallback)
# 启动应用
adb shell am start -n $activity
# 睡眠10s并等待perfetto退出
# 睡眠15s并等待perfetto退出
sleep 10
wait
@ -194,7 +172,7 @@ for round in $(seq 1 $cycle); do
adb shell cat /proc/vmstat > $dir/system_mem/after_vmstat-$app-$round
# 睡眠3s后拉simpleperf和perfetto数据
sleep $WAIT
sleep $wait
adb pull /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace $dir/traces
adb pull /data/local/tmp/simpleperf-"$app"-"$round".txt $dir/simpleperf/
adb shell "rm /data/misc/perfetto-traces/trace-"$app"-"$round".ptrace"
@ -265,6 +243,10 @@ for round in $(seq 1 $cycle); do
echo $round $app $start_type $start_time $rss $pss $pagefaults $minorfaults $majorfaults $itlbmiss $dtlbmiss $cpustall $inc_ratio $inc_total $order4_ratio $order4_cont $nr_inc_direct_reclaim >> $dir/result
if [ $clear_background -ne 0 ]; then
./clearapp.sh
fi
rm tmp.txt
done
done