DankMaterialShell icon indicating copy to clipboard operation
DankMaterialShell copied to clipboard

DgopService: fixed updateInterval ignores the power profile, and each refresh spawns a process

Open Mark2Mac opened this issue 3 months ago • 0 comments

Summary

DgopService.updateInterval is hardcoded and does not follow the active power profile, while every refresh spawns an external process. In power-saver the rest of the shell slows down and this does not, so two parts of the same interface visibly run at different rates.

Services/DgopService.qml:15

property int updateInterval: refCount > 0 ? 3000 : 30000

The timer at line ~632 drives updateAllStats(), which runs dgopProcess.

Why the process spawn matters

A fork plus an exec costs orders of magnitude more than a frame: pages to map, a binary to load, a scheduler run — and it pulls the CPU package out of deep idle every time. At 3 s that is ~1200 process spawns per hour, and it keeps going as long as any consumer holds a reference. A single bar widget showing CPU is enough.

I measured the same pattern in three bar widgets of my own that each spawned a helper per tick. Cost of the startup alone, not the work:

helper language CPU per spawn
(mine, Python) Python 48–52 ms
dgop Go 3 ms

Three Python helpers at one round every 1.3 s cost 11.8 % of a core. Replacing them with a single long-lived daemon that publishes a file brought it to 0.69 %. For scale, turning off all shell animations was worth 0.30 points of a core — a fortieth of that.

dgop is much cheaper because it is compiled, so DMS's case is far less severe. But the structure is identical, and a fixed interval makes it needlessly frequent exactly when the user has asked to save power.

Suggested fix

Keep the existing two regimes, make the values depend on the profile:

readonly property var _intervals: ({
    "performance": { active: 1500, idle: 30000 },
    "balanced":    { active: 3000, idle: 30000 },
    "power-saver": { active: 6000, idle: 60000 }
})
readonly property var _regime: _intervals[PowerProfiles.profile] || _intervals["balanced"]
property int updateInterval: refCount > 0 ? _regime.active : _regime.idle

The balanced values are identical to today's, so default behaviour is unchanged for anyone not using power profiles.

Local workaround

updateInterval is a writable property, so a daemon plugin can assign it and take over without patching /usr. That is what I am doing meanwhile; happy to send a PR with the above if you'd prefer it upstream.

Environment

DankMaterialShell / Quickshell 0.3.0 (Arch), niri 26.04, Intel i7-1165G7.

Mark2Mac avatar Aug 09 '26 23:08 Mark2Mac