delayWorker: stop loop for static modules with no exec command#5123
Open
martuscellifaria wants to merge 3 commits into
Open
delayWorker: stop loop for static modules with no exec command#5123martuscellifaria wants to merge 3 commits into
martuscellifaria wants to merge 3 commits into
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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 grepalex 1938 0.0 0.0 8516 3388 tty2 S+ 06:40 0:00 /bin/sh -c waybar & swaync & hypridle & hyprpaperalex 77380 11.6 0.1 788096 60124 pts/11 Sl+ 09:24 0:01 ./build/waybarThe 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", sinceinterval_.count() == 0skippeddelayWorker()entirely, commit 2b552f7 forces a minimum of 1ms, which makesdelayWorker()start and calldp.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; }