Skip to content

🎨 Palette: Improve Game Loop Efficiency#12

Open
aidasofialily-cmd wants to merge 2 commits intomainfrom
palette-ux-event-loop-efficiency-15303406226419221875
Open

🎨 Palette: Improve Game Loop Efficiency#12
aidasofialily-cmd wants to merge 2 commits intomainfrom
palette-ux-event-loop-efficiency-15303406226419221875

Conversation

@aidasofialily-cmd
Copy link
Copy Markdown
Owner

💡 What: Refactored the main game loop to use a single, blocking poll() call with a dynamically calculated timeout. This replaces the previous inefficient busy-wait loop that combined a non-blocking poll() with a fixed sleep_for().

🎯 Why: The original implementation caused unnecessary CPU wakeups, leading to high resource consumption and potentially laggy input. The new approach allows the OS to sleep the process efficiently, reducing CPU usage and making the game feel more responsive. This is a non-visual UX improvement focused on performance and smoothness.

Accessibility: While not a direct accessibility feature, reducing CPU load can improve the experience for users on low-power devices or those running assistive technologies that are sensitive to system performance.


PR created automatically by Jules for task 15303406226419221875 started by @aidasofialily-cmd

Refactors the main game loop to use a single, blocking `poll()` call
with a dynamic timeout.

The previous implementation used an inefficient busy-wait pattern with a
non-blocking `poll()` and a fixed `std::this_thread::sleep_for()`.
This caused high CPU usage and unnecessary wakeups.

This change calculates the remaining time until the next tick and uses
it as the timeout for `poll()`, allowing the process to sleep
efficiently. This significantly reduces CPU consumption and improves
input responsiveness, enhancing the overall user experience.

Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com>
@google-labs-jules
Copy link
Copy Markdown
Contributor

👋 Jules, reporting for duty! I'm here to lend a hand with this pull request.

When you start a review, I'll add a 👀 emoji to each comment to let you know I've read it. I'll focus on feedback directed at me and will do my best to stay out of conversations between you and other bots or reviewers to keep the noise down.

I'll push a commit with your requested changes shortly after. Please note there might be a delay between these steps, but rest assured I'm on the job!

For more direct control, you can switch me to Reactive Mode. When this mode is on, I will only act on comments where you specifically mention me with @jules. You can find this option in the Pull Request section of your global Jules UI settings. You can always switch back!

New to Jules? Learn more at jules.google/docs.


For security, I will only act on instructions from the user who triggered this task.

- Adds a "Press any key to start..." prompt to improve the initial user experience.
- Refactors the main game loop to use a more efficient and responsive `poll()`-based timer.
- Fixes the CI workflow to correctly build and test the C++ project.

Co-authored-by: aidasofialily-cmd <247843425+aidasofialily-cmd@users.noreply.github.com>
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

Successfully merging this pull request may close these issues.

1 participant