From 5223e6e3bc627da586c2c3f68698531c209125ae Mon Sep 17 00:00:00 2001 From: Adnan Hodzic Date: Thu, 17 Sep 2020 22:16:37 +0200 Subject: [PATCH] turbo trigger revamp, use more conservative settings (#109, #118) --- source/core.py | 30 +++++++++++++++++++----------- 1 file changed, 19 insertions(+), 11 deletions(-) diff --git a/source/core.py b/source/core.py index cc7efe0..c71eb7a 100644 --- a/source/core.py +++ b/source/core.py @@ -36,6 +36,10 @@ load1m, _, _ = os.getloadavg() # get CPU utilization as a percentage cpuload = psutil.cpu_percent(interval=1) +# powersave/performance load thresholds +powersave_load_threshold = (50*CPUS)/100 +performance_load_threshold = (25*CPUS)/100 + # auto-cpufreq log file auto_cpufreq_log_file = Path("/var/log/auto-cpufreq.log") auto_cpufreq_log_file_snap = Path("/var/snap/auto-cpufreq/current/auto-cpufreq.log") @@ -310,7 +314,7 @@ def set_powersave(): display_load() # conditions for setting turbo in powersave - if load1m > (15*CPUS)/100: + if load1m > powersave_load_threshold: print("High load, setting turbo boost: on") turbo(True) elif psutil.cpu_percent(percpu=False, interval=0.01) >= 25.0 or isclose(max(psutil.cpu_percent(percpu=True, interval=0.01)), 100): @@ -329,7 +333,7 @@ def mon_powersave(): # cpu usage/system load display_load() - if load1m > (15*CPUS)/100: + if load1m > powersave_load_threshold: print("High load, suggesting to set turbo boost: on") get_turbo() footer() @@ -354,7 +358,7 @@ def set_performance(): # cpu usage/system load display_load() - if load1m >= (10*CPUS)/100: + if load1m >= performance_load_threshold: print("High load, setting turbo boost: on") turbo(True) elif psutil.cpu_percent(percpu=False, interval=0.01) >= 15.0 or isclose(max(psutil.cpu_percent(percpu=True, interval=0.01)), 100): @@ -369,18 +373,22 @@ def set_performance(): # make turbo suggestions in performance def mon_performance(): - + # cpu usage/system load display_load() - if turbo(): - print("Currently turbo boost is: on") - print("Suggesting to set turbo boost: on") + if load1m > performance_load_threshold: + print("High load, suggesting to set turbo boost: on") + get_turbo() + footer() + elif psutil.cpu_percent(percpu=False, interval=0.01) >= 25.0 or isclose(max(psutil.cpu_percent(percpu=True, interval=0.01)), 100): + print("High CPU load, suggesting to set turbo boost: on") + get_turbo() + footer() else: - print("Currently turbo boost is: off") - print("Suggesting to set turbo boost: on") - - footer() + print("Load optimal, suggesting to set turbo boost: off") + get_turbo() + footer() def set_autofreq():