Skip to content

delayWorker: stop loop for static modules with no exec command#5123

Open
martuscellifaria wants to merge 3 commits into
Alexays:masterfrom
martuscellifaria:master
Open

delayWorker: stop loop for static modules with no exec command#5123
martuscellifaria wants to merge 3 commits into
Alexays:masterfrom
martuscellifaria:master

Conversation

@martuscellifaria

Copy link
Copy Markdown

Hi! I am kind of new here.
I was customizing my Waybar for a couple of days and noticed a strange CPU usage spike when I add a custom separator to my config.jsonc file with interval set to 0:
"custom/sep": { "format": "|", "interval": 0 }.
This was the usage of the current v0.15.0:
ps aux | grep waybar | grep -v grep
alex 1938 0.0 0.0 8516 3388 tty2 S+ 06:40 0:00 /bin/sh -c waybar & swaync & hypridle & hyprpaper
alex 77380 11.6 0.1 788096 60124 pts/11 Sl+ 09:24 0:01 ./build/waybar
The usage spike was similar in two machines I have. Namely an ArmSoM Sige7 Pro Max and a Lenovo Ideapad Z400 Touch, both running Arch Linux, so Arm/x86 have the same behavior.

I then tracked the commits down, between v0.14.0 and v.0.15.0 and found out that commit 2b552f7 (2b552f7f) produced a side effect on setting interval = 0. Instead of the earlier behavior where interval 0 was treated as "don't start a worker", since interval_.count() == 0 skipped delayWorker() entirely, commit 2b552f7 forces a minimum of 1ms, which makes delayWorker() start and call dp.emit() in a continuous loop — even for modules with no exec command.

To have both of the new behavior of correcting sub-ms accidents and the "don't update when 0", I added the following check, so the delayWorker() function returns early if there is nothing to execute.:
if (!config_["exec"].isString() && !config_["exec-if"].isString()) { dp.emit(); return; }

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.

1 participant