Fix high idle CPU usage on Windows #11
Open
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.
Running a project rendering a rectangle and a simple gradient shader at 60fps, it was taking up 14-17% of my CPU.
Added a small check so it sleeps only when necessary, at a reasonable stability.
CPU usage is now 2-4%.
Compared to an empty project at the same fps and no libraries, the difference is just 1%.
I did run it on Linux, 1-3% usage vs 5% originally.
An adaptive affinity was added to compensate for high fps. Lower values produce more consistent frametimes at the cost of higher CPU usage.
The affinity formula is simplified from this equation:
( 1 - (tick.framerate - 60) / (240-60) ) * 0.35 + 0.5
Tested in LÖVE 11.5