Skip to content

Commit ff25124

Browse files
committed
优化调度配置中关于原神进程监视的实现
1 parent 0951c30 commit ff25124

3 files changed

Lines changed: 69 additions & 96 deletions

File tree

app/src/main/assets/powercfg/kona/powercfg-utils.sh

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -437,38 +437,45 @@ yuan_shen_opt_run() {
437437
fi
438438
}
439439

440-
# watch_app [time] [on_tick] [on_change]
440+
# watch_app [on_tick] [on_change]
441441
watch_app() {
442-
local interval="$1"
443-
local on_tick="$2"
444-
local on_change="$3"
442+
local interval=120
443+
local on_tick="$1"
444+
local on_change="$2"
445445
local app=$(getprop vtools.powercfg_app)
446446

447447
if [[ "$on_tick" == "" ]]; then
448448
return
449449
fi
450450

451-
local prop='vtools.perf.watch'
452-
453-
local current_watch=$(getprop $prop)
454-
if [[ "$current_watch" != "" ]]; then
455-
kill -9 $current_watch 2>/dev/null
456-
setprop $prop ""
457-
fi
458-
459451
if [[ "$app" == "" ]]; then
460452
return
461453
fi
462454

463-
setprop $prop "$$"
455+
procs=$(pgrep -f com.omarea.*powercfg.sh)
456+
last_proc=$(echo "$procs" | tail -n 1)
457+
if [[ "$last_proc" != "" ]]; then
458+
echo "$procs" | grep -v "$last_proc" | while read pid; do
459+
kill -9 $pid 2> /dev/null
460+
done
461+
fi
462+
463+
ticks=0
464464
while true
465465
do
466-
sleep $interval
466+
if [[ $ticks -gt 3 ]]; then
467+
sleep $interval
468+
elif [[ $ticks -gt 0 ]]; then
469+
sleep 30
470+
else
471+
sleep 10
472+
fi
473+
ticks=$((ticks + 1))
474+
467475
current=$(getprop vtools.powercfg_app)
468476
if [[ "$current" == "$app" ]]; then
469477
$on_tick $current
470478
else
471-
setprop $prop ""
472479
if [[ "$on_change" ]]; then
473480
$on_change $current
474481
fi
@@ -477,19 +484,6 @@ watch_app() {
477484
done
478485
}
479486

480-
yuan_shen_opt() {
481-
sleep 10
482-
yuan_shen_opt_run
483-
sleep 35
484-
yuan_shen_opt_run
485-
sleep 30
486-
yuan_shen_opt_run
487-
sleep 30
488-
yuan_shen_opt_run
489-
490-
watch_app 120 yuan_shen_opt_run
491-
}
492-
493487
adjustment_by_top_app() {
494488
case "$top_app" in
495489
# YuanShen
@@ -504,7 +498,6 @@ adjustment_by_top_app() {
504498
set_cpu_freq 1036800 1804800 1478400 1766400 1075200 2265600
505499
set_hispeed_freq 1708800 1766400 2073600
506500
sched_limit 5000 0 5000 0 5000 0
507-
yuan_shen_opt &
508501
elif [[ "$action" = "balance" ]]; then
509502
sched_boost 1 0
510503
stune_top_app 1 10
@@ -513,23 +506,21 @@ adjustment_by_top_app() {
513506
set_cpu_freq 1036800 1804800 1056000 2054400 1075200 2457600
514507
set_hispeed_freq 1708800 1056000 1075200
515508
sched_limit 5000 0 5000 0 5000 0
516-
yuan_shen_opt &
517509
elif [[ "$action" = "performance" ]]; then
518510
sched_boost 1 0
519511
stune_top_app 1 10
520512
gpu_pl_down 1
521513
set_cpu_freq 1036800 1420800 1056000 2419200 1075200 2841600
522514
set_hispeed_freq 1708800 1766400 1747200
523515
sched_limit 5000 0 5000 0 5000 0
524-
yuan_shen_opt &
525516
elif [[ "$action" = "fast" ]]; then
526517
sched_boost 1 0
527518
stune_top_app 1 100
528519
sched_limit 5000 0 10000 0 5000 0
529-
yuan_shen_opt &
530520
# sched_config "40 60" "50 75" "120" "150"
531521
fi
532522
cpuset '0-1' '0-3' '0-7' '0-7'
523+
watch_app yuan_shen_opt_run &
533524
;;
534525

535526

app/src/main/assets/powercfg/lahaina/powercfg-utils.sh

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -446,38 +446,45 @@ yuan_shen_opt_run() {
446446
fi
447447
}
448448

449-
# watch_app [time] [on_tick] [on_change]
449+
# watch_app [on_tick] [on_change]
450450
watch_app() {
451-
local interval="$1"
452-
local on_tick="$2"
453-
local on_change="$3"
451+
local interval=120
452+
local on_tick="$1"
453+
local on_change="$2"
454454
local app=$(getprop vtools.powercfg_app)
455455

456456
if [[ "$on_tick" == "" ]]; then
457457
return
458458
fi
459459

460-
local prop='vtools.perf.watch'
461-
462-
local current_watch=$(getprop $prop)
463-
if [[ "$current_watch" != "" ]]; then
464-
kill -9 $current_watch 2>/dev/null
465-
setprop $prop ""
466-
fi
467-
468460
if [[ "$app" == "" ]]; then
469461
return
470462
fi
471463

472-
setprop $prop "$$"
464+
procs=$(pgrep -f com.omarea.*powercfg.sh)
465+
last_proc=$(echo "$procs" | tail -n 1)
466+
if [[ "$last_proc" != "" ]]; then
467+
echo "$procs" | grep -v "$last_proc" | while read pid; do
468+
kill -9 $pid 2> /dev/null
469+
done
470+
fi
471+
472+
ticks=0
473473
while true
474474
do
475-
sleep $interval
475+
if [[ $ticks -gt 3 ]]; then
476+
sleep $interval
477+
elif [[ $ticks -gt 0 ]]; then
478+
sleep 30
479+
else
480+
sleep 10
481+
fi
482+
ticks=$((ticks + 1))
483+
476484
current=$(getprop vtools.powercfg_app)
477485
if [[ "$current" == "$app" ]]; then
478486
$on_tick $current
479487
else
480-
setprop $prop ""
481488
if [[ "$on_change" ]]; then
482489
$on_change $current
483490
fi
@@ -486,19 +493,6 @@ watch_app() {
486493
done
487494
}
488495

489-
yuan_shen_opt() {
490-
sleep 10
491-
yuan_shen_opt_run
492-
sleep 30
493-
yuan_shen_opt_run
494-
sleep 30
495-
yuan_shen_opt_run
496-
sleep 30
497-
yuan_shen_opt_run
498-
499-
watch_app 120 yuan_shen_opt_run
500-
}
501-
502496
adjustment_by_top_app() {
503497
case "$top_app" in
504498
# YuanShen
@@ -518,7 +512,6 @@ adjustment_by_top_app() {
518512
set_cpu_freq 1036800 1708800 710400 1670400 844800 1670400
519513
# set_gpu_max_freq 540000000
520514
set_gpu_max_freq 491000000
521-
yuan_shen_opt &
522515
elif [[ "$action" = "balance" ]]; then
523516
if [[ "$manufacturer" == "Xiaomi" ]]; then
524517
conservative_mode 55 67 70 89 71 89
@@ -531,7 +524,6 @@ adjustment_by_top_app() {
531524
set_cpu_freq 1036800 1708800 960000 1996800 844800 2035200
532525
set_hispeed_freq 1708800 1440000 1075200
533526
set_gpu_max_freq 676000000
534-
yuan_shen_opt &
535527
elif [[ "$action" = "performance" ]]; then
536528
# bw_max_always
537529
if [[ "$manufacturer" == "Xiaomi" ]]; then
@@ -542,7 +534,6 @@ adjustment_by_top_app() {
542534
stune_top_app 0 0
543535
set_cpu_freq 806400 1708800 710400 2419200 844800 2841600
544536
set_gpu_max_freq 738000000
545-
yuan_shen_opt &
546537
elif [[ "$action" = "fast" ]]; then
547538
bw_max_always
548539
if [[ "$manufacturer" == "Xiaomi" ]]; then
@@ -552,9 +543,9 @@ adjustment_by_top_app() {
552543
stune_top_app 1 55
553544
# sched_config "40 60" "50 75" "120" "150"
554545
set_gpu_max_freq 778000000
555-
yuan_shen_opt &
556546
fi
557547
cpuset '0-1' '0-1' '0-7' '0-7'
548+
watch_app yuan_shen_opt_run &
558549
;;
559550

560551
# Wang Zhe Rong Yao

app/src/main/assets/powercfg/msmnile/powercfg-utils.sh

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -402,38 +402,45 @@ yuan_shen_opt_run() {
402402
fi
403403
}
404404

405-
# watch_app [time] [on_tick] [on_change]
405+
# watch_app [on_tick] [on_change]
406406
watch_app() {
407-
local interval="$1"
408-
local on_tick="$2"
409-
local on_change="$3"
407+
local interval=120
408+
local on_tick="$1"
409+
local on_change="$2"
410410
local app=$(getprop vtools.powercfg_app)
411411

412412
if [[ "$on_tick" == "" ]]; then
413413
return
414414
fi
415415

416-
local prop='vtools.perf.watch'
417-
418-
local current_watch=$(getprop $prop)
419-
if [[ "$current_watch" != "" ]]; then
420-
kill -9 $current_watch 2>/dev/null
421-
setprop $prop ""
422-
fi
423-
424416
if [[ "$app" == "" ]]; then
425417
return
426418
fi
427419

428-
setprop $prop "$$"
420+
procs=$(pgrep -f com.omarea.*powercfg.sh)
421+
last_proc=$(echo "$procs" | tail -n 1)
422+
if [[ "$last_proc" != "" ]]; then
423+
echo "$procs" | grep -v "$last_proc" | while read pid; do
424+
kill -9 $pid 2> /dev/null
425+
done
426+
fi
427+
428+
ticks=0
429429
while true
430430
do
431-
sleep $interval
431+
if [[ $ticks -gt 3 ]]; then
432+
sleep $interval
433+
elif [[ $ticks -gt 0 ]]; then
434+
sleep 30
435+
else
436+
sleep 10
437+
fi
438+
ticks=$((ticks + 1))
439+
432440
current=$(getprop vtools.powercfg_app)
433441
if [[ "$current" == "$app" ]]; then
434442
$on_tick $current
435443
else
436-
setprop $prop ""
437444
if [[ "$on_change" ]]; then
438445
$on_change $current
439446
fi
@@ -442,19 +449,6 @@ watch_app() {
442449
done
443450
}
444451

445-
yuan_shen_opt() {
446-
sleep 10
447-
yuan_shen_opt_run
448-
sleep 50
449-
yuan_shen_opt_run
450-
sleep 30
451-
yuan_shen_opt_run
452-
sleep 30
453-
yuan_shen_opt_run
454-
455-
watch_app 120 yuan_shen_opt_run
456-
}
457-
458452
adjustment_by_top_app() {
459453
case "$top_app" in
460454
# YuanShen
@@ -469,7 +463,6 @@ adjustment_by_top_app() {
469463
set_cpu_freq 1036800 1785600 1497600 1804800 1056000 2227200
470464
set_hispeed_freq 1708800 1708800 2016000
471465
sched_limit 5000 0 5000 0 5000 0
472-
yuan_shen_opt &
473466
elif [[ "$action" = "balance" ]]; then
474467
sched_boost 1 0
475468
stune_top_app 1 10
@@ -478,23 +471,21 @@ adjustment_by_top_app() {
478471
set_cpu_freq 1036800 1785600 1056000 2016000 1056000 2419200
479472
set_hispeed_freq 1708800 1056000 1056000
480473
sched_limit 5000 0 5000 0 5000 0
481-
yuan_shen_opt &
482474
elif [[ "$action" = "performance" ]]; then
483475
sched_boost 1 0
484476
stune_top_app 1 10
485477
gpu_pl_down 1
486478
set_cpu_freq 1036800 1478400 1056000 2419200 1056000 2841600
487479
set_hispeed_freq 1708800 1708800 1708800
488480
sched_limit 5000 0 5000 0 5000 0
489-
yuan_shen_opt &
490481
elif [[ "$action" = "fast" ]]; then
491482
sched_boost 1 0
492483
stune_top_app 1 100
493484
sched_limit 5000 0 10000 0 5000 0
494485
# sched_config "40 60" "50 75" "120" "150"
495-
yuan_shen_opt &
496486
fi
497487
cpuset '0-1' '0-3' '0-7' '0-7'
488+
watch_app yuan_shen_opt_run &
498489
;;
499490

500491
# Wang Zhe Rong Yao

0 commit comments

Comments
 (0)