Skip to content

Commit

Permalink
DEV 20200513
Browse files Browse the repository at this point in the history
uperf:ProcGetUid采用busybox中的方法,可能与AffinityHelper死循环有关
uperf:下调滑动距离阈值,减少滑动误认为是点击
uperf:延迟UI响应的Hint恢复时间范围增加到700ms
SfAnalysis:有些时候刚开始滑动就遇到卡顿,误报交给uperf压制非交互时的boost解决
wipe-v2:配置文件:评分函数权重和参数范围回调一些
配置文件生成器:降低卡顿模式的sfLag的频率拉升
配置文件生成器:骁龙712最大主频2.3g
安装脚本:设置enable_sfanalysis标志位,如果遇到与她相关的卡屏可删除此标志位禁用SfAnalysis
自启动脚本:关闭`sleep 60`有助于解决小米10 MIUI12启动器不响应触摸的情况
自启动脚本:wait_until_login测试目录可写权限
once:补充关闭一些热插拔

Signed-off-by: Matt Yang <[email protected]>
  • Loading branch information
yc9559 committed May 13, 2020
1 parent b28b6db commit fdbf037
Show file tree
Hide file tree
Showing 11 changed files with 80 additions and 173 deletions.
36 changes: 0 additions & 36 deletions magisk/README.md

This file was deleted.

10 changes: 7 additions & 3 deletions magisk/initsvc_uperf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,15 @@ BASEDIR="$(dirname $(readlink -f "$0"))"
wait_until_login()
{
# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
while [ ! -d "/sdcard/Android" ]; do
sleep 2
local test_file
test_file="/sdcard/Android/$(mktemp -u XXXXXXXX)"
while [ ! -f "$test_file" ]; do
touch "$test_file"
sleep 1
done
rm "$test_file"
}

wait_until_login
sleep 60
# do not sleep 60, may causing MIUI 12 launcher freezed by sfanalysis
sh $BASEDIR/run_uperf.sh
2 changes: 1 addition & 1 deletion magisk/module.prop
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
id=uperf
name=Uperf
version=DEV 20200507
version=DEV 20200513
versionCode=1
author=Matt Yang
description=Userspace performance controller for android. Repo: https://github.com/yc9559/uperf/
Expand Down
2 changes: 1 addition & 1 deletion magisk/run_uperf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,6 @@ chmod 755 /data/powercfg-base.sh
# powercfg path provided by magisk module
echo "sh $SCRIPT_DIR/powercfg_main.sh \"\$1\"" >> /data/powercfg.sh

# not relying on executable permissions
sh $SCRIPT_DIR/start_sfanalysis.sh
sh $SCRIPT_DIR/powercfg_main.sh
sh $SCRIPT_DIR/powercfg_once.sh
10 changes: 7 additions & 3 deletions magisk/script/libcommon.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Basic Tool Library
# https://github.com/yc9559/
# Author: Matt Yang
# Version: 20200507
# Version: 20200513

BASEDIR="$(dirname "$0")"
. $BASEDIR/pathinfo.sh
Expand Down Expand Up @@ -70,9 +70,13 @@ clear_panel()
wait_until_login()
{
# we doesn't have the permission to rw "/sdcard" before the user unlocks the screen
while [ ! -d "/sdcard/Android" ]; do
sleep 2
local test_file
test_file="/sdcard/Android/$(mktemp -u XXXXXXXX)"
while [ ! -f "$test_file" ]; do
touch "$test_file"
sleep 1
done
rm "$test_file"
}

###############################
Expand Down
6 changes: 5 additions & 1 deletion magisk/script/libuperf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ UPERF_NAME="uperf"
###############################

uperf_config_path="$MODULE_PATH/config/cfg_uperf.json"
uperf_log_path="/sdcard/Android/log_uperf.log"
uperf_log_path="/sdcard/Android/log_uperf.txt"
uperf_powermode_node="/data/uperf_powermode"

# $1:mode_name
Expand Down Expand Up @@ -52,6 +52,10 @@ uperf_start()
lock_val "131072" /proc/sys/fs/inotify/max_user_watches
lock_val "1024" /proc/sys/fs/inotify/max_user_instances

# cleanup
rm /sdcard/Android/log_uperf.log
rm /sdcard/Android/log_uperf.log.bak

# start uperf
"$MODULE_PATH/$UPERF_REL/$UPERF_NAME" -o "$uperf_log_path" "$uperf_config_path" 2>> "$uperf_log_path"
# waiting for uperf initialization
Expand Down
2 changes: 1 addition & 1 deletion magisk/script/powercfg_main.sh
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ save_panel()
write_panel ""
write_panel "Uperf https://github.com/yc9559/uperf/"
write_panel "Author: Matt Yang"
write_panel "Version: DEV 20200507"
write_panel "Version: DEV 20200513"
write_panel "Last performed: $(date '+%Y-%m-%d %H:%M:%S')"
write_panel ""
write_panel "[Uperf status]"
Expand Down
58 changes: 40 additions & 18 deletions magisk/script/powercfg_once.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ BASEDIR="$(dirname "$0")"
. $BASEDIR/libcommon.sh
. $BASEDIR/libpowercfg.sh
. $BASEDIR/libuperf.sh
. $BASEDIR/libsfanalysis.sh

# unify schedtune misc
# android 10 doesn't have schedtune.sched_boost_enabled exposed, default = true
Expand Down Expand Up @@ -71,20 +70,20 @@ change_thread_cgroup "system_server" "android.ui" "top-app" "stune"
# ...and pin HeapTaskDaemon on LITTLE
change_thread_cgroup "system_server" "HeapTaskDaemon" "background" "cpuset"

# # reduce big cluster wakeup, eg. [email protected]
# change_task_cgroup ".hardware." "background" "cpuset"
# change_task_affinity ".hardware." "0f"
# # ...but exclude fingerprint&camera&display service for speed
# change_task_cgroup ".hardware.biometrics.fingerprint" "" "cpuset"
# change_task_cgroup ".hardware.camera.provider" "" "cpuset"
# change_task_cgroup ".hardware.display" "" "cpuset"
# change_task_affinity ".hardware.biometrics.fingerprint" "ff"
# change_task_affinity ".hardware.camera.provider" "ff"
# change_task_affinity ".hardware.display" "ff"
# reduce big cluster wakeup, eg. [email protected]
change_task_cgroup ".hardware." "background" "cpuset"
change_task_affinity ".hardware." "0f"
# ...but exclude fingerprint&camera&display service for speed
change_task_cgroup ".hardware.biometrics.fingerprint" "" "cpuset"
change_task_cgroup ".hardware.camera.provider" "" "cpuset"
change_task_cgroup ".hardware.display" "" "cpuset"
change_task_affinity ".hardware.biometrics.fingerprint" "ff"
change_task_affinity ".hardware.camera.provider" "ff"
change_task_affinity ".hardware.display" "ff"

# provide best performance for fingerprint service
change_task_cgroup ".hardware.biometrics.fingerprint" "rt" "stune"
change_task_nice ".hardware.biometrics.fingerprint" "-20"
change_task_cgroup ".hardware.biometrics." "rt" "stune"
change_task_nice ".hardware.biometrics." "-20"
mutate "100" $ST_RT/schedtune.boost
mutate "1" $ST_RT/schedtune.prefer_idle

Expand Down Expand Up @@ -141,9 +140,10 @@ lock_val "0" /sys/module/cpu_input_boost/parameters/flex_boost_freq_hp
lock_val "0" /sys/module/cpu_input_boost/parameters/flex_boost_freq_lp
lock_val "0" /sys/module/devfreq_boost/parameters/input_boost_duration

# stop qualcomm perfd
# try to disable all other userspace performance daemon
# Qualcomm perfd
stop perfd
# stop qualcomm perfd
# Qualcomm perfhal
perfhal_stop
# brain service maybe not smart
stop oneplus_brain_service
Expand All @@ -154,12 +154,37 @@ stop oneplus_brain_service
# stop vendor.power-hal-1-2
# stop vendor.power-hal-1-3

# try to disable all hotplug
# Qualcomm Battery Current Limit
for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
echo -n "disable" > $mode
done
for hotplug_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_mask; do
lock_val "0" $hotplug_mask
done
for hotplug_soc_mask in /sys/devices/soc.0/qcom,bcl.*/hotplug_soc_mask; do
lock_val "0" $hotplug_soc_mask
done
for mode in /sys/devices/soc.0/qcom,bcl.*/mode; do
echo -n "enable" > $mode
done
# Exynos hotplug
mutate "0" /sys/power/cpuhotplug/enabled
mutate "0" $CPU/cpuhotplug/enabled
# turn off msm_thermal
lock_val "0" /sys/module/msm_thermal/core_control/enabled
lock_val "N" /sys/module/msm_thermal/parameters/enabled
# maybe CAF
lock_val "0" /proc/sys/kernel/hotplug
lock_val "1" $CPU/cpu0/rq-stats/hotplug_disable
# AllWinner H6
lock_val "1" /sys/kernel/autohotplug/boost_all
# 3rd
lock_val "0" /sys/kernel/intelli_plug/intelli_plug_active
lock_val "0" /sys/module/blu_plug/parameters/enabled
lock_val "0" /sys/devices/virtual/misc/mako_hotplug_control/enabled
lock_val "0" /sys/module/autosmp/parameters/enabled
lock_val "0" /sys/kernel/zen_decision/enabled
# bring all cores online
for i in 0 1 2 3 4 5 6 7 8 9; do
mutate "1" $CPU/cpu$i/online
Expand Down Expand Up @@ -225,9 +250,6 @@ lock_val "1" $LPM/lpm_prediction
lock_val "0" $LPM/sleep_disabled
lock_val "25" $LPM/bias_hyst

# start surfaceflinger analysis
sfa_start

# start uperf once only
uperf_stop
uperf_start
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Surfaceflinger Analysis Library
# https://github.com/yc9559/
# Author: Matt Yang
# Version: 20200507
# Version: 20200513

BASEDIR="$(dirname "$0")"
. $BASEDIR/pathinfo.sh
Expand Down Expand Up @@ -43,3 +43,5 @@ sfa_start()
echo "$(date '+%Y-%m-%d %H:%M:%S')" > /cache/injector.log
"$MODULE_PATH/$SFA_REL/$SFA_NAME" "/system/bin/surfaceflinger" "$lib_path" >> /cache/injector.log
}

[ -f "$MODULE_PATH/enable_sfanalysis" ] && sfa_start
18 changes: 15 additions & 3 deletions magisk/setup_uperf.sh
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
# Uperf Setup
# https://github.com/yc9559/
# Author: Matt Yang & cjybyjk ([email protected])
# Version: 20200507
# Version: 20200513

BASEDIR="$(dirname $(readlink -f "$0"))"

Expand Down Expand Up @@ -109,6 +109,15 @@ _get_sdm865_type()
fi
}

_get_sdm76x_type()
{
if [ "$(cat /sys/devices/soc0/revision)" == "2.0" ]; then
echo "sdm768"
else
echo "sdm765"
fi
}

_get_msm8916_type()
{
case "$(_get_socid)" in
Expand Down Expand Up @@ -258,7 +267,7 @@ _get_cfgname()
"kona") ret="$(_get_sdm865_type)" ;;
"msmnile") ret="sdm855" ;;
"sdm845") ret="sdm845" ;;
"lito") ret="sdm765" ;;
"lito") ret="$(_get_sdm76x_type)" ;;
"sm6150") ret="$(_get_sm6150_type)" ;;
"sdm710") ret="sdm710" ;;
"msm8916") ret="$(_get_msm8916_type)" ;;
Expand Down Expand Up @@ -290,7 +299,7 @@ uperf_print_banner()
echo ""
echo "* Uperf https://github.com/yc9559/uperf/"
echo "* Author: Matt Yang"
echo "* Version: DEV 20200507"
echo "* Version: DEV 20200513"
echo ""
}

Expand Down Expand Up @@ -340,6 +349,9 @@ sfa_install()
_set_perm "$target_lib_path/libsfanalysis.so" 0 0 0644 u:object_r:system_lib_file:s0
# in case of set_perm_recursive is broken
chmod 0755 $BASEDIR/bin/*

# create sfanalysis enable flag
touch $BASEDIR/enable_sfanalysis
}

powerhal_stub_install()
Expand Down
Loading

0 comments on commit fdbf037

Please sign in to comment.