Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

CPU at 100% during game #310

Open
adangert opened this issue Sep 9, 2023 · 3 comments
Open

CPU at 100% during game #310

adangert opened this issue Sep 9, 2023 · 3 comments

Comments

@adangert
Copy link
Owner

adangert commented Sep 9, 2023

Joustmania eats all the CPU processes, we should find a way to not have the controller processes eat up all the available resources. from this comment: #307 (comment)

@adangert
Copy link
Owner Author

Instead of polling all the time in a while loop, we may be able to just look at the buffer for each controller and pull packets as necessary, when we do the rework here: #289

@ekobres
Copy link

ekobres commented Oct 28, 2024

The CPU thrashing is caused by a few uncontrolled loops running full throttle.
I have a fork with fixes for these - essentially some strategically placed time.sleep() calls.
To help with figuring out which processes were thrashing, I added titles to all of the processes.

I used different sleep values for different loops depending on what they were doing - either 10ms, 30ms, or 500ms.

Here's what htop looks like with my changes:

Screenshot 2024-10-27 at 11 14 22 PM

If you are interested, I will create a pull request.

I have not tested it with Windows - only on a RP 4. There is a lot of concurrency in this project, so it's possible adding these sleeps could expose a race condition or other issue, but so far these changes seem to be working well for me.

@janlugt
Copy link

janlugt commented Oct 28, 2024

Amazing! That would come along way to making Joustmania run better on a battery. Right now it really eats through them very fast.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants