Fix high CPU usage when game paused#32
Merged
Merged
Conversation
jserv
requested changes
Jul 16, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Check https://cbea.ms/git-commit/ carefully and enforce.
Contributor
|
Provide test case for clarification/validation. |
Contributor
Author
|
Before this patch After this patch |
Contributor
Author
|
Initialize read_attr to false instead of relying on Ctrl-P to reproduce the issue deterministically. Without the patch, select() continues monitoring the readable device file descriptor and returns immediately, causing a busy loop and a significant increase in CPU usage. With the patch applied, the device file descriptor is excluded and select() blocks on standard input, keeping CPU usage negligible. |
jserv
requested changes
Jul 17, 2026
jserv
left a comment
Contributor
There was a problem hiding this comment.
Check https://cbea.ms/git-commit/ carefully and enforce the rules.
When board display is paused, read_attr prevents task_io from consuming data from /dev/kxo. The descriptor can remain readable, so keeping it in the select set makes select return immediately and repeatedly run the main loop. Exclude /dev/kxo from the descriptor set and wait only for stdin while paused. This lets select sleep until keyboard input resumes or exits the program, avoiding needless CPU use. Change-Id: I5c44adeed192167998cc71ca3174bc0edc50cdc4
Contributor
|
Thank @tobiichi3227 for contributing! |
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.
Stop reading
kxodevice when game is paused.Only read STDIN for resume game.
Change-Id: I5c44adeed192167998cc71ca3174bc0edc50cdc4
Summary by cubic
Fix high CPU use when paused by excluding
/dev/kxofromselectand waiting only onSTDIN.Written for commit 0000878. Summary will update on new commits.