Skip to content

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

Closed

Description

@lesquoyb

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

Activity

  1. hqnghi88 commented on Aug 27, 2024

    @hqnghi88
    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);

  2. lesquoyb commented on Aug 27, 2024

    @lesquoyb
    ContributorAuthor

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

  3. hqnghi88 commented on Aug 27, 2024

    @hqnghi88
    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.

  4. lesquoyb commented on Aug 27, 2024

    @lesquoyb
    ContributorAuthor

    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 😄

  5. hqnghi88 commented on Aug 27, 2024

    @hqnghi88
    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)

  6. added a commit that references this issue on Aug 27, 2024
    c2e4b25
  7. added a commit that references this issue on Aug 27, 2024
    771e2cd
  8. moved this from Todo to Done in GAMA 2025-06on Jun 30, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    About GAMA ServerThis issue concerns GAMA server usageEnhancementThis is a request for enhancement

    Type

    No type

    Projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions