Lighter Weight Signal-Based Custom Modules #2517
Merged
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.
These changes are intended to fix a performance problem I had on my laptop where using signals on my custom modules would cause excess CPU usage and battery drainage.
This PR makes it so that any custom module with an undefined
interval
but a definedsignal
will start up a thread with the newCustom::waitingWorker()
function. This is identical to aninterval
based update with signals but will instead sleep indefinitely using a newSleeperThread::sleep()
function.Aside from making this a usable combination of config options this is higher performance than both the
"once"
option and any given integer interval. Full disclaimer, I am not an optimizations expert but waybar's CPU usage went from between 0.4% and 0.6% (sometimes getting much higher but I haven't recorded that and it might not actually be waybar's fault) to between 0.0% and 0.1% with these additions (CPU usage recorded with btop++).Please tell me if anything should be changed, thanks! :D