You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
[GS] when waiting for connection gama-server uses 100% of one cpu core continuously #281
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:
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:
I can't find another core that is constantly close to 100% though
To Reproduce
Steps to reproduce the behavior:
Run gama-server
let the initialization finish (because that would be normal to take up the most cpu possible at that time)
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
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);
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 😄
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)
Activity
hqnghi88 commentedon Aug 27, 2024
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 commentedon Aug 27, 2024
It did work! Isn't there a more "elegant" way to do it though?
hqnghi88 commentedon Aug 27, 2024
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 commentedon Aug 27, 2024
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 commentedon Aug 27, 2024
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)
Fixes #281
Merge pull request #300 from gama-platform/fix-281