sysstats: refresh cpuFreq every 3rd tick instead of every tick
/proc/cpuinfo is regenerated in full by the kernel on every read and its cost grows with core count, making it the priciest per-tick read. Bar frequency display doesn't need 1 Hz precision. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
@@ -52,6 +52,12 @@ Singleton {
|
|||||||
// poll interval in seconds
|
// poll interval in seconds
|
||||||
readonly property int interval: 1
|
readonly property int interval: 1
|
||||||
|
|
||||||
|
// cpuFreq comes from /proc/cpuinfo, which the kernel regenerates in full on
|
||||||
|
// every read (cost grows with core count) — the priciest per-tick read here.
|
||||||
|
// Frequency on a status bar doesn't need 1 Hz precision, so only refresh it
|
||||||
|
// every Nth tick instead of on the CPU%/mem hot path.
|
||||||
|
readonly property int freqEveryTicks: 3
|
||||||
|
|
||||||
// discovered sysfs paths (filled once by discover.sh)
|
// discovered sysfs paths (filled once by discover.sh)
|
||||||
property string tempPath: ""
|
property string tempPath: ""
|
||||||
property string batPath: ""
|
property string batPath: ""
|
||||||
@@ -271,15 +277,17 @@ Singleton {
|
|||||||
}
|
}
|
||||||
|
|
||||||
function _tickOnce() {
|
function _tickOnce() {
|
||||||
|
const doFreq = root._tick % root.freqEveryTicks === 0;
|
||||||
|
|
||||||
statView.reload();
|
statView.reload();
|
||||||
cpuInfoView.reload();
|
if (doFreq) cpuInfoView.reload();
|
||||||
memView.reload();
|
memView.reload();
|
||||||
routeView.reload();
|
routeView.reload();
|
||||||
if (root.tempPath) tempView.reload();
|
if (root.tempPath) tempView.reload();
|
||||||
if (root.batPath) { batCapView.reload(); batStatusView.reload(); }
|
if (root.batPath) { batCapView.reload(); batStatusView.reload(); }
|
||||||
|
|
||||||
_parseCpu();
|
_parseCpu();
|
||||||
_parseFreq();
|
if (doFreq) _parseFreq();
|
||||||
_parseMem();
|
_parseMem();
|
||||||
_parseTemp();
|
_parseTemp();
|
||||||
_parseBattery();
|
_parseBattery();
|
||||||
|
|||||||
Reference in New Issue
Block a user