Skip to content

cpu_usage: reuse previous values on rapid refreshes#559

Open
whoismz wants to merge 1 commit into
i3:mainfrom
whoismz:main
Open

cpu_usage: reuse previous values on rapid refreshes#559
whoismz wants to merge 1 commit into
i3:mainfrom
whoismz:main

Conversation

@whoismz

@whoismz whoismz commented Jun 29, 2026

Copy link
Copy Markdown

Fixes #442.

cpu_usage is calculated from the delta between two CPU time samples. When i3status is refreshed again before the configured interval has elapsed, the sampling window can be too small and the reported percentage becomes noisy.

This can be observed when changing volume while both the volume and cpu_usage modules are enabled: changing the volume can cause cpu_usage to show an artificial spike.

This patch reuses the previous overall and per-CPU usage values for refreshes that happen before the configured interval, and avoids advancing the previous CPU sample in that case.

Tested on Arch Linux with i3, i3status, PipeWire/PulseAudio, and a config using both volume master and cpu_usage.

cpu_usage is calculated from the delta between two CPU time samples. When
i3status is refreshed again before the configured interval has elapsed,
the sampling window can be too small and the reported percentage becomes
noisy.

This can be observed when changing volume while both the volume and
cpu_usage modules are enabled.

Reuse the previous overall and per-CPU usage values for refreshes that
happen before the configured interval, and avoid advancing the previous CPU
sample in that case. This keeps CPU usage sampling aligned with the
configured interval and avoids artificial spikes on rapid refreshes.

Fixes i3#442
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Bug: changing volume affects CPU usage

1 participant