gamercade-io / gamercade_console

A Neo-Retro Fantasy Console. Make WASM-powered, networked multiplayer games.
https://gamercade.io
Apache License 2.0
166 stars 10 forks source link

High CPU usage in Editor only when idle #36

Closed Cardosaum closed 1 year ago

Cardosaum commented 1 year ago

I noticed that, in stand-by, the Editor consumes quite a lot of CPU resources even though it shouldn't as there is no event triggering any functionality in the UI.

I'm running the editor using the command: cargo run --release --bin gamercade_editor

There is always 100% usage in the thread running gamercade_editor, but ideally it would be almost negligible as its idle most of the time.

Interestingly enough, I noticed that if I interact with the program (moving the mouse around in the application, or clicking into buttons) the CPU usage actually drops to 0.6% ~ 4.2%.

Maybe when the editor is idle, the even loop simply runs at max speed without any sleep or something like that?


My system specs: CPU: AMD Ryzen 9 5950X (32) @ 3.400GHz GPU: NVIDIA Geforce RTX 3050 Memory: 32GB (not sure if it's relevant, but using i3wm)

$ uname --kernel-name --kernel-release --kernel-version
Linux 5.15.60-1-MANJARO #1 SMP PREEMPT Thu Aug 11 13:14:05 UTC 2022
RobDavenport commented 1 year ago

Thank's for your detailed report @Cardosaum , could you see if this PR solves your issue? #37

Cardosaum commented 1 year ago

~I tested the latest one, but unfortunately the behavior remains the same. It might be something Linux (or even X11?) specific.~

Problem solved when testing the correct branch :sweat_smile:

Thank you for fixing it so fast! :rocket: