From 8432e1dcdcc704ff2d6bf2f3b42f680a553b929d Mon Sep 17 00:00:00 2001 From: ooonea <35407790+ooonea@users.noreply.github.com> Date: Sun, 19 Apr 2026 21:56:36 +0200 Subject: [PATCH] Efficiency: drop the duplicate is_on_battery call in power_thread In polling mode, power['source'] is already set from is_on_battery at the top of each iteration, so the HWP check was calling is_on_battery a second time for the same value. Replace the whole dbus-vs-polling branch with `power['source'] == 'AC'`, which is correct for both methods and avoids the extra glob/file read (and a fallback DBus round-trip). Signed-off-by: ooonea <35407790+ooonea@users.noreply.github.com> --- throttled.py | 9 +-------- 1 file changed, 1 insertion(+), 8 deletions(-) diff --git a/throttled.py b/throttled.py index 574a228..31e0d18 100755 --- a/throttled.py +++ b/throttled.py @@ -787,14 +787,7 @@ def power_thread(config, regs, exit_event, cpuid): wait_t = config.getfloat(power['source'], 'Update_Rate_s') enable_hwp_mode = config.getboolean('AC', 'HWP_Mode', fallback=None) # set HWP less frequently. Just to be safe since (e.g.) TLP might reset this value - if ( - enable_hwp_mode - and next_hwp_write <= time() - and ( - (power['method'] == 'dbus' and power['source'] == 'AC') - or (power['method'] == 'polling' and not is_on_battery(config)) - ) - ): + if enable_hwp_mode and next_hwp_write <= time() and power['source'] == 'AC': set_hwp(enable_hwp_mode) next_hwp_write = time() + HWP_INTERVAL