fix(iwyu_tool): reduce CPU usage in job polling loop#2005
Merged
kimgr merged 1 commit intoinclude-what-you-use:masterfrom Apr 18, 2026
Merged
Conversation
The job polling loop was sleeping 100 microseconds (10,000 wakeups/sec), causing unnecessary CPU usage when waiting for IWYU analysis jobs that take seconds to complete. 100ms (10 polls/sec) is sufficient granularity for jobs that run for seconds, with no perceptible impact on responsiveness. Addresses include-what-you-use#1995 Signed-off-by: Pierluigi Lenoci <pierluigilenoci@gmail.com>
Contributor
Author
|
Hi @kimgr, @bolshakov-a — this is a small fix to reduce CPU usage in the job polling loop in |
Contributor
|
Looks reasonable, but I have no idea how to find the optimum value. |
Contributor
|
LGTM. I remember experimenting with that poll delay (it was originally zero), but I see now that we're in no rush since we're just monitoring comparatively long-running child processes. Makes sense. |
Informational: IWYU dogfood resultsinclude-what-you-use (exit: 0)fix_includes.py (exit: 0) |
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.
Fixes #1995
The job scheduling loop in
iwyu_tool.pyusedtime.sleep(0.0001)(100us), causing 10,000 wakeups per second while waiting for IWYU analysis jobs that typically run for seconds.This PR changes the sleep interval to
0.1seconds (10 polls/sec), which is more than sufficient granularity for long-running jobs and significantly reduces CPU and battery usage during analysis runs.