From 96ac1ee65da31055704e0a14cafacc33914d7e86 Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Wed, 30 Sep 2026 19:56:48 +0200 Subject: perf(dashboard): draw at 0.1s only while the dashboard is visible Conky gives Lua no way to request one redraw, so a scroll showed up to 2s late. Pointer enter and leave, which Hyprland sends on every toggle of the special workspace, now switch conky_set_update_interval between 0.1s and the config's 2s. At that rate the CPU and network counters would sample over 0.1s windows and the chart would fill 20x faster, so both now sample through data.new_gate on the /proc/uptime clock, about every 2s, and redraw their last values in between. The samplers move to texeci: execi runs in the main loop and a 0.7s nvtable or an Immich download stalled the scroll. Measured: about 12% of one core while visible, 0.5% while hidden. Co-Authored-By: Claude Opus 5.5 --- lib/data.lua | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'lib') diff --git a/lib/data.lua b/lib/data.lua index 4b31f43..7ae96a7 100644 --- a/lib/data.lua +++ b/lib/data.lua @@ -631,6 +631,26 @@ function M.immich_parse(text) return out end +-- A sampling gate for counters that are read per draw. The dashboard draws +-- every 0.1s while it is on screen, and a CPU or byte counter sampled that +-- often gives coarse, flickering deltas, so those cards sample on this gate +-- and redraw their last values in between. +-- +-- The returned function answers true at most once per `every` seconds, plus +-- the clock it used: /proc/uptime, because os.time() counts whole seconds and +-- a rate divided by a rounded interval is off by up to half. `now` is for the +-- test. An unreadable clock opens the gate, which is the old per-draw behaviour. +function M.new_gate(every) + local last + return function(now) + now = now or tonumber((M.slurp('/proc/uptime') or ''):match('^(%S+)')) + if not now then return true, nil end + if last and now - last < every then return false, now end + last = now + return true, now + end +end + -- nvtable's plain table (`nvtable -C -E`), as bin/updates-sample.sh caches it: -- -- [personal] foo-bin 1.14.9 -> 1.14.9 !! ~ 1.14.10 -- cgit v1.2.3