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

[GS] when waiting for connection gama-server uses 100% of one cpu core continuously #281

Closed
lesquoyb opened this issue Aug 14, 2024 · 5 comments
Labels
About GAMA Server This issue concerns GAMA server usage 🤗 Enhancement This is a request for enhancement

Comments

@lesquoyb
Copy link
Contributor

Describe the bug
I've noticed that gama-server is using close to 100% continuously of one of my cpu's core. It is not doing anything, just waiting for a client to connect so in my opinion it should have minimal cpu use.
Here is the cpu use from the windows task manager:
image
I'm not sure how windows gets to 9.6% but using 100% of one performance core on my computer would account for approx. 8% of the "maximum cumulated capacity" of the cpu if that makes sense. And in any case it should be 0 or 1% like the other processes that are idle.

If I look in the details it is pretty clear that at least one core gets overloaded as soon as I start gama-server, and never goes down:
image
I can't find another core that is constantly close to 100% though

To Reproduce
Steps to reproduce the behavior:

  1. Run gama-server
  2. let the initialization finish (because that would be normal to take up the most cpu possible at that time)
  3. Observer that one core is completely used by gs

Expected behavior
gama-server should use minimum cpu when it's just idling and just waiting for clients to connect, like all other programs that have network capabilities do.

Desktop (please complete the following information):
Tested on multiple windows computers, I'm quite sure I saw that on linux too but it needs to be checked

@lesquoyb lesquoyb added 🤗 Enhancement This is a request for enhancement About GAMA Server This issue concerns GAMA server usage labels Aug 14, 2024
@hqnghi88
Copy link
Member

Hi,
It may come from the infinite loop which is not optimized for server listening task. If you can try in: GamaHeadlessWebSocketServer , replace line 194 by (the while true)
Thread.sleep(999999999);

@lesquoyb
Copy link
Contributor Author

It did work! Isn't there a more "elegant" way to do it though?

@hqnghi88
Copy link
Member

You mean a more "serverly"? wrapping by a server architecture, because GS is now just as a specific launch mode of (headless) java application.

@lesquoyb
Copy link
Contributor Author

Yes I feel like there must be something better to do than just make the thread sleep a fixed amount of time. But maybe I'm wrong, anyway it still works with the sleep line so if there's no obvious other way that will do the trick 😄

@hqnghi88
Copy link
Member

Yes i totally agree on the implementation using server technologies, just find out when we will do it.
Anyway a 99999999999l seems equals to "infinite loops" unless it is bad to tell the main thread to sleep (but it does nothing in this case)

hqnghi88 added a commit that referenced this issue Aug 27, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
About GAMA Server This issue concerns GAMA server usage 🤗 Enhancement This is a request for enhancement
Projects
None yet
Development

No branches or pull requests

2 participants