Skip to content

Commit

Permalink
优化调度配置中关于原神进程监视的实现
Browse files Browse the repository at this point in the history
  • Loading branch information
helloklf committed Aug 10, 2021
1 parent 0951c30 commit ff25124
Show file tree
Hide file tree
Showing 3 changed files with 69 additions and 96 deletions.
55 changes: 23 additions & 32 deletions app/src/main/assets/powercfg/kona/powercfg-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -437,38 +437,45 @@ yuan_shen_opt_run() {
fi
}

# watch_app [time] [on_tick] [on_change]
# watch_app [on_tick] [on_change]
watch_app() {
local interval="$1"
local on_tick="$2"
local on_change="$3"
local interval=120
local on_tick="$1"
local on_change="$2"
local app=$(getprop vtools.powercfg_app)

if [[ "$on_tick" == "" ]]; then
return
fi

local prop='vtools.perf.watch'

local current_watch=$(getprop $prop)
if [[ "$current_watch" != "" ]]; then
kill -9 $current_watch 2>/dev/null
setprop $prop ""
fi

if [[ "$app" == "" ]]; then
return
fi

setprop $prop "$$"
procs=$(pgrep -f com.omarea.*powercfg.sh)
last_proc=$(echo "$procs" | tail -n 1)
if [[ "$last_proc" != "" ]]; then
echo "$procs" | grep -v "$last_proc" | while read pid; do
kill -9 $pid 2> /dev/null
done
fi

ticks=0
while true
do
sleep $interval
if [[ $ticks -gt 3 ]]; then
sleep $interval
elif [[ $ticks -gt 0 ]]; then
sleep 30
else
sleep 10
fi
ticks=$((ticks + 1))

current=$(getprop vtools.powercfg_app)
if [[ "$current" == "$app" ]]; then
$on_tick $current
else
setprop $prop ""
if [[ "$on_change" ]]; then
$on_change $current
fi
Expand All @@ -477,19 +484,6 @@ watch_app() {
done
}

yuan_shen_opt() {
sleep 10
yuan_shen_opt_run
sleep 35
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run

watch_app 120 yuan_shen_opt_run
}

adjustment_by_top_app() {
case "$top_app" in
# YuanShen
Expand All @@ -504,7 +498,6 @@ adjustment_by_top_app() {
set_cpu_freq 1036800 1804800 1478400 1766400 1075200 2265600
set_hispeed_freq 1708800 1766400 2073600
sched_limit 5000 0 5000 0 5000 0
yuan_shen_opt &
elif [[ "$action" = "balance" ]]; then
sched_boost 1 0
stune_top_app 1 10
Expand All @@ -513,23 +506,21 @@ adjustment_by_top_app() {
set_cpu_freq 1036800 1804800 1056000 2054400 1075200 2457600
set_hispeed_freq 1708800 1056000 1075200
sched_limit 5000 0 5000 0 5000 0
yuan_shen_opt &
elif [[ "$action" = "performance" ]]; then
sched_boost 1 0
stune_top_app 1 10
gpu_pl_down 1
set_cpu_freq 1036800 1420800 1056000 2419200 1075200 2841600
set_hispeed_freq 1708800 1766400 1747200
sched_limit 5000 0 5000 0 5000 0
yuan_shen_opt &
elif [[ "$action" = "fast" ]]; then
sched_boost 1 0
stune_top_app 1 100
sched_limit 5000 0 10000 0 5000 0
yuan_shen_opt &
# sched_config "40 60" "50 75" "120" "150"
fi
cpuset '0-1' '0-3' '0-7' '0-7'
watch_app yuan_shen_opt_run &
;;


Expand Down
55 changes: 23 additions & 32 deletions app/src/main/assets/powercfg/lahaina/powercfg-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -446,38 +446,45 @@ yuan_shen_opt_run() {
fi
}

# watch_app [time] [on_tick] [on_change]
# watch_app [on_tick] [on_change]
watch_app() {
local interval="$1"
local on_tick="$2"
local on_change="$3"
local interval=120
local on_tick="$1"
local on_change="$2"
local app=$(getprop vtools.powercfg_app)

if [[ "$on_tick" == "" ]]; then
return
fi

local prop='vtools.perf.watch'

local current_watch=$(getprop $prop)
if [[ "$current_watch" != "" ]]; then
kill -9 $current_watch 2>/dev/null
setprop $prop ""
fi

if [[ "$app" == "" ]]; then
return
fi

setprop $prop "$$"
procs=$(pgrep -f com.omarea.*powercfg.sh)
last_proc=$(echo "$procs" | tail -n 1)
if [[ "$last_proc" != "" ]]; then
echo "$procs" | grep -v "$last_proc" | while read pid; do
kill -9 $pid 2> /dev/null
done
fi

ticks=0
while true
do
sleep $interval
if [[ $ticks -gt 3 ]]; then
sleep $interval
elif [[ $ticks -gt 0 ]]; then
sleep 30
else
sleep 10
fi
ticks=$((ticks + 1))

current=$(getprop vtools.powercfg_app)
if [[ "$current" == "$app" ]]; then
$on_tick $current
else
setprop $prop ""
if [[ "$on_change" ]]; then
$on_change $current
fi
Expand All @@ -486,19 +493,6 @@ watch_app() {
done
}

yuan_shen_opt() {
sleep 10
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run

watch_app 120 yuan_shen_opt_run
}

adjustment_by_top_app() {
case "$top_app" in
# YuanShen
Expand All @@ -518,7 +512,6 @@ adjustment_by_top_app() {
set_cpu_freq 1036800 1708800 710400 1670400 844800 1670400
# set_gpu_max_freq 540000000
set_gpu_max_freq 491000000
yuan_shen_opt &
elif [[ "$action" = "balance" ]]; then
if [[ "$manufacturer" == "Xiaomi" ]]; then
conservative_mode 55 67 70 89 71 89
Expand All @@ -531,7 +524,6 @@ adjustment_by_top_app() {
set_cpu_freq 1036800 1708800 960000 1996800 844800 2035200
set_hispeed_freq 1708800 1440000 1075200
set_gpu_max_freq 676000000
yuan_shen_opt &
elif [[ "$action" = "performance" ]]; then
# bw_max_always
if [[ "$manufacturer" == "Xiaomi" ]]; then
Expand All @@ -542,7 +534,6 @@ adjustment_by_top_app() {
stune_top_app 0 0
set_cpu_freq 806400 1708800 710400 2419200 844800 2841600
set_gpu_max_freq 738000000
yuan_shen_opt &
elif [[ "$action" = "fast" ]]; then
bw_max_always
if [[ "$manufacturer" == "Xiaomi" ]]; then
Expand All @@ -552,9 +543,9 @@ adjustment_by_top_app() {
stune_top_app 1 55
# sched_config "40 60" "50 75" "120" "150"
set_gpu_max_freq 778000000
yuan_shen_opt &
fi
cpuset '0-1' '0-1' '0-7' '0-7'
watch_app yuan_shen_opt_run &
;;

# Wang Zhe Rong Yao
Expand Down
55 changes: 23 additions & 32 deletions app/src/main/assets/powercfg/msmnile/powercfg-utils.sh
Original file line number Diff line number Diff line change
Expand Up @@ -402,38 +402,45 @@ yuan_shen_opt_run() {
fi
}

# watch_app [time] [on_tick] [on_change]
# watch_app [on_tick] [on_change]
watch_app() {
local interval="$1"
local on_tick="$2"
local on_change="$3"
local interval=120
local on_tick="$1"
local on_change="$2"
local app=$(getprop vtools.powercfg_app)

if [[ "$on_tick" == "" ]]; then
return
fi

local prop='vtools.perf.watch'

local current_watch=$(getprop $prop)
if [[ "$current_watch" != "" ]]; then
kill -9 $current_watch 2>/dev/null
setprop $prop ""
fi

if [[ "$app" == "" ]]; then
return
fi

setprop $prop "$$"
procs=$(pgrep -f com.omarea.*powercfg.sh)
last_proc=$(echo "$procs" | tail -n 1)
if [[ "$last_proc" != "" ]]; then
echo "$procs" | grep -v "$last_proc" | while read pid; do
kill -9 $pid 2> /dev/null
done
fi

ticks=0
while true
do
sleep $interval
if [[ $ticks -gt 3 ]]; then
sleep $interval
elif [[ $ticks -gt 0 ]]; then
sleep 30
else
sleep 10
fi
ticks=$((ticks + 1))

current=$(getprop vtools.powercfg_app)
if [[ "$current" == "$app" ]]; then
$on_tick $current
else
setprop $prop ""
if [[ "$on_change" ]]; then
$on_change $current
fi
Expand All @@ -442,19 +449,6 @@ watch_app() {
done
}

yuan_shen_opt() {
sleep 10
yuan_shen_opt_run
sleep 50
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run
sleep 30
yuan_shen_opt_run

watch_app 120 yuan_shen_opt_run
}

adjustment_by_top_app() {
case "$top_app" in
# YuanShen
Expand All @@ -469,7 +463,6 @@ adjustment_by_top_app() {
set_cpu_freq 1036800 1785600 1497600 1804800 1056000 2227200
set_hispeed_freq 1708800 1708800 2016000
sched_limit 5000 0 5000 0 5000 0
yuan_shen_opt &
elif [[ "$action" = "balance" ]]; then
sched_boost 1 0
stune_top_app 1 10
Expand All @@ -478,23 +471,21 @@ adjustment_by_top_app() {
set_cpu_freq 1036800 1785600 1056000 2016000 1056000 2419200
set_hispeed_freq 1708800 1056000 1056000
sched_limit 5000 0 5000 0 5000 0
yuan_shen_opt &
elif [[ "$action" = "performance" ]]; then
sched_boost 1 0
stune_top_app 1 10
gpu_pl_down 1
set_cpu_freq 1036800 1478400 1056000 2419200 1056000 2841600
set_hispeed_freq 1708800 1708800 1708800
sched_limit 5000 0 5000 0 5000 0
yuan_shen_opt &
elif [[ "$action" = "fast" ]]; then
sched_boost 1 0
stune_top_app 1 100
sched_limit 5000 0 10000 0 5000 0
# sched_config "40 60" "50 75" "120" "150"
yuan_shen_opt &
fi
cpuset '0-1' '0-3' '0-7' '0-7'
watch_app yuan_shen_opt_run &
;;

# Wang Zhe Rong Yao
Expand Down

0 comments on commit ff25124

Please sign in to comment.