ENH use trigger to control when HWP query fires

This commit is contained in:
Nathan Dwarshuis 2021-07-13 23:50:50 -04:00
parent 3efe2d8b6b
commit b25bd994ae
2 changed files with 18 additions and 9 deletions

View File

@ -198,16 +198,20 @@ local _read_hwp = function()
end end
end end
local update = function(cr) local update = function(cr, trigger)
local conky = Util.conky local conky = Util.conky
local load_sum = 0 local load_sum = 0
-- TODO bundle all the crap down below into this function and make it return
-- something useful rather than totally use a side effect (it will be mildly
-- slower)
-- this entire loop is about 10% total execution time
_read_cpu() _read_cpu()
for c = 1, NUM_PHYSICAL_CORES do for c = 1, NUM_PHYSICAL_CORES do
local core = cores[c] local core = cores[c]
for t = 1, NUM_THREADS_PER_CORE do for t = 1, NUM_THREADS_PER_CORE do
-- TODO these might not match the actual core numbers (if I care)
local cl = cpu_loads[(c - 1) * NUM_THREADS_PER_CORE + t] local cl = cpu_loads[(c - 1) * NUM_THREADS_PER_CORE + t]
-- this is necessary to prevent 1/0 errors -- this is necessary to prevent 1/0 errors
if cl.total > cl.total_prev then if cl.total > cl.total_prev then
@ -223,7 +227,12 @@ local update = function(cr)
) )
end end
-- For some reason this call is slow (querying anything with pstate in
-- general seems slow), but I also don't need to see an update every cycle,
-- hence the trigger
if trigger == 0 then
Common.text_rows_set(cpu_status, cr, 1, _read_hwp()) Common.text_rows_set(cpu_status, cr, 1, _read_hwp())
end
Common.text_rows_set(cpu_status, cr, 2, _read_freq()) Common.text_rows_set(cpu_status, cr, 2, _read_freq())
Common.percent_plot_set(total_load, cr, load_sum / NCPU * 100) Common.percent_plot_set(total_load, cr, load_sum / NCPU * 100)
@ -275,8 +284,8 @@ M.draw_static = function(cr)
Table.draw_static(tbl, cr) Table.draw_static(tbl, cr)
end end
M.draw_dynamic = function(cr) M.draw_dynamic = function(cr, trigger)
update(cr) update(cr, trigger)
for c = 1, NUM_PHYSICAL_CORES do for c = 1, NUM_PHYSICAL_CORES do
local this_core = cores[c] local this_core = cores[c]

View File

@ -237,7 +237,7 @@ function conky_main()
System.draw_dynamic(cr, pacman_stats) System.draw_dynamic(cr, pacman_stats)
Graphics.draw_dynamic(cr) Graphics.draw_dynamic(cr)
Processor.draw_dynamic(cr) Processor.draw_dynamic(cr, t1)
ReadWrite.draw_dynamic(cr, UPDATE_FREQUENCY) ReadWrite.draw_dynamic(cr, UPDATE_FREQUENCY)
Network.draw_dynamic(cr, UPDATE_FREQUENCY) Network.draw_dynamic(cr, UPDATE_FREQUENCY)