Skip to content

Commit

Permalink
DEV 20200428
Browse files Browse the repository at this point in the history
Sfanalysis:通过注入自定义动态库,推测并向外部传递渲染开始、渲染提交滞后、渲染结束事件
Sfanalysis:增加自适应动态刷新率、自适应vsync信号滞后间隔
Sfanalysis:在SELinux的权限范围内,向外部传递信号,因此不需要关闭SELinux才能使用
Sfanalysis:在一加7Pro(Android 10)、坚果Pro2(Android 8.1)、Nexus9(Android 7.1)测试通过
uperf:增加Sfanalysis,响应从surfaceflinger传递来的渲染事件
uperf:增加HintSflag,在收到渲染提交滞后之后,在观察到掉帧之前,拉升到最大性能保持0.015秒
uperf:借助Sfanalysis的渲染结束事件,hint提前结束延时从0.2s降低到0.06s
uperf:限制进入sfLag次数限制,每超过400ms间隔可用次数+1,最大到15次
uperf:修复当之前的最低频高于后来的最高频时,设置会无效
uperf:增加DelayedWork,改善定时器资源利用
uperf:尝试修复AffinityHelper死循环
uperf:uxaffinity类型knob交给affinity helper去重
uperf:进入standby后休眠PmMonitor线程
uperf:重构inotifier,改进逻辑一致性
状态转移:备份进入overlay类型hint之前的base类型hint
配置文件生成器:sfLag动作如果是3集群例如sdm855,负载大多数时候在中核,因此中核需要更高的频率
配置文件生成器:高通EAS的费电模式提供更多性能
配置文件生成器:上调一点Exynos 9820中核频率
安装脚本:细分解析msm8916,修复sdm615平台始终安装失败
Makefile:迁移到ndkbuild,编译后二进制大小67k->51k,或许能改进兼容性问题

Signed-off-by: Matt Yang <yccy@outlook.com>
  • Loading branch information
yc9559 committed Apr 28, 2020
1 parent f3a63e9 commit cc06ab4
Show file tree
Hide file tree
Showing 10 changed files with 111 additions and 7 deletions.
3 changes: 2 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ Userspace performance controller for android

## Credit

@AndroidDumps
[@AndroidDumps](https://github.com/AndroidDumps)
[@shunix](https://github.com/shunix)
@HEX_Stan(coolapk)
@僞裝灬(coolapk)
@Yoooooo(coolapk)
Expand Down
2 changes: 1 addition & 1 deletion magisk/makezip.sh
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ zipname="uperf-magisk.zip"
echo "Compile Uperf binary..."
cd ..
make clean 1> /dev/null
make release -j8 1> /dev/null
make ndkbuild 1> /dev/null

echo "Compile Uperf configs..."
cd config
Expand Down
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 20200421
version=DEV 20200428
versionCode=1
author=Matt Yang
description=Userspace performance controller for android. Repo: https://github.com/yc9559/uperf/
Expand Down
11 changes: 10 additions & 1 deletion 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: 20200404
# Version: 20200426

BASEDIR="$(dirname "$0")"
. $BASEDIR/pathinfo.sh
Expand Down Expand Up @@ -174,3 +174,12 @@ get_platform_name()
{
echo "$(getprop ro.board.platform)"
}

is_aarch64()
{
if [ "$(getprop ro.product.cpu.abi)" == "arm64-v8a" ]; then
echo "true"
else
echo "false"
fi
}
38 changes: 38 additions & 0 deletions magisk/script/libsfanalysis.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,38 @@
#!/system/bin/sh
# Surfaceflinger Analysis Library
# https://github.com/yc9559/
# Author: Matt Yang
# Version: 20200426

BASEDIR="$(dirname "$0")"
. $BASEDIR/pathinfo.sh
. $BASEDIR/libcommon.sh

###############################
# PATHs
###############################

SFA_REL="$BIN_DIR"
SFA_NAME="injector"
SFA_LIB="libsfanalysis.so"

###############################
# SfAnalysis tool functions
###############################

sfa_start()
{
# raise inotify limit
lock_val "131072" /proc/sys/fs/inotify/max_queued_events
lock_val "131072" /proc/sys/fs/inotify/max_user_watches
lock_val "1024" /proc/sys/fs/inotify/max_user_instances

local lib_path
if [ "$(is_aarch64)" == "true" ]; then
lib_path="/system/lib64/$SFA_LIB"
else
lib_path="/system/lib/$SFA_LIB"
fi

"$MODULE_PATH/$SFA_REL/$SFA_NAME" "/system/bin/surfaceflinger" "$lib_path"
}
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 20200421"
write_panel "Version: DEV 20200428"
write_panel "Last performed: $(date '+%Y-%m-%d %H:%M:%S')"
write_panel ""
write_panel "[Uperf status]"
Expand Down
4 changes: 4 additions & 0 deletions magisk/script/powercfg_once.sh
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@ 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 @@ -224,5 +225,8 @@ 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_start
56 changes: 54 additions & 2 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 (cjybyjk@gmail.com)
# Version: 20200421
# Version: 20200428

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

Expand Down Expand Up @@ -35,6 +35,15 @@ _set_perm_recursive() {
done
}

_is_aarch64()
{
if [ "$(getprop ro.product.cpu.abi)" == "arm64-v8a" ]; then
echo "true"
else
echo "false"
fi
}

_is_eas()
{
if [ "$(grep sched /sys/devices/system/cpu/cpu0/cpufreq/scaling_available_governors)" != "" ]; then
Expand All @@ -61,6 +70,15 @@ _get_maxfreq()
echo "$maxfreq"
}

_get_socid()
{
if [ -f /sys/devices/soc0/soc_id ]; then
echo "$(cat /sys/devices/soc0/soc_id)"
else
echo "$(cat /sys/devices/system/soc/soc0/id)"
fi
}

_get_sm6150_type()
{
[ -f /sys/devices/soc0/soc_id ] && SOC_ID="$(cat /sys/devices/soc0/soc_id)"
Expand All @@ -86,6 +104,16 @@ _get_sdm865_type()
fi
}

_get_msm8916_type()
{
case "$(_get_socid)" in
"206"|"247"|"248"|"249"|"250") echo "msm8916" ;;
"233"|"240"|"242") echo "sdm610" ;;
"239"|"241"|"263"|"268"|"269"|"270"|"271") echo "sdm616" ;;
*) echo "msm8916" ;;
esac
}

_get_sdm636_type()
{
if [ "$(_is_eas)" == "true" ]; then
Expand Down Expand Up @@ -212,6 +240,7 @@ _get_cfgname()
"lito") ret="sdm765" ;;
"sm6150") ret="$(_get_sm6150_type)" ;;
"sdm710") ret="sdm710" ;;
"msm8916") ret="$(_get_msm8916_type)" ;;
"msm8939") ret="sdm616" ;;
"msm8953") ret="$(_get_sdm625_type)" ;;
"msm8953pro") ret="$(_get_sdm626_type)" ;;
Expand Down Expand Up @@ -239,7 +268,7 @@ uperf_print_banner()
echo ""
echo "* Uperf https://github.com/yc9559/uperf/"
echo "* Author: Matt Yang"
echo "* Version: DEV 20200421"
echo "* Version: DEV 20200428"
echo ""
}

Expand Down Expand Up @@ -269,5 +298,28 @@ uperf_install()
echo "- Uperf installation was successful."
}

sfa_install()
{
local sfanalysis_path
local target_lib_path
if [ "$(_is_aarch64)" == "true" ]; then
sfanalysis_path="$BASEDIR/sfanalysis/arm64-v8a"
target_lib_path="$BASEDIR/system/lib64"
else
sfanalysis_path="$BASEDIR/sfanalysis/armeabi-v7a"
target_lib_path="$BASEDIR/system/lib"
fi

mkdir -p "$target_lib_path"
cp "$sfanalysis_path/injector" "$BASEDIR/bin/"
cp "$sfanalysis_path/libsfanalysis.so" "$target_lib_path"

_set_perm "$BASEDIR/bin/injector" 0 0 0755 u:object_r:system_file:s0
_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/*
}

uperf_print_banner
uperf_install
sfa_install
Binary file added magisk/sfanalysis/arm64-v8a/injector
Binary file not shown.
Binary file added magisk/sfanalysis/armeabi-v7a/injector
Binary file not shown.

0 comments on commit cc06ab4

Please sign in to comment.