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

WIP: Decouple game and ui frame rates #100

Draft
wants to merge 3 commits into
base: master
Choose a base branch
from
Draft

WIP: Decouple game and ui frame rates #100

wants to merge 3 commits into from

Conversation

ngc92
Copy link
Collaborator

@ngc92 ngc92 commented Feb 17, 2023

This is some work in progress towards decoupling the frame rate of the ui and the game simulation, and also with the goal of getting rid of the monstrosity half-singleton with function-level statics that is the current SpeedController.

It is still unfinished, single player mostly works but I haven't tested network or replays.
Still, I hope this can serve as a foundation to discuss and design what we want to achieve.

Some observations:

  1. Do we still need the show-fps option? On desktops, you almost certainly should be able to achieve the target fps nowadays, and on mobile you won't really see the title bar change in any case.
  2. Ultimately, I would like to move game and ui to different threads. Even cheap mobile devices nowadays have multiple cores, so that should help further ensure good performance.
  3. How to do the waiting. Right now I'm using std::this_thread::yield(), but that seems to generate still 100% CPU on linux.
  4. Increase granularity of game simulation. Instead of 75 steps per second, e.g. 150. This allows more precise input (high-end desktop with 140 Hz monitor might want to run input at the same frequency) and makes the blobby positions seem less discrete (e.g. more variety when serving). Should not be problematic from a computation point of view, currently I can run about 20k game steps per second on a single thread.
  5. Instead of spawning on thread per game on the server, have a pre-existing thread pool (configurable) and assign new games to these threads. With non-blocking speed control, we can have games with different speeds on the same thread.

Thoughs?

@ngc92 ngc92 marked this pull request as draft February 17, 2023 13:00
@ngc92 ngc92 requested a review from danielknobe February 17, 2023 13:00
@ngc92 ngc92 added enhancement New feature or request question Further information is requested labels Feb 17, 2023
@ngc92
Copy link
Collaborator Author

ngc92 commented Feb 18, 2023

So, point 4 is a bit more involved, as the bot scripts have parts that use hard-coded numerical constants that may depend on details of the game simulation. I still think it is a good change, but we have to go over the bot scripts and make adjustments accordingly. Ideally also getting rid of as many fixed constants as possible.
Some of the things I've noticed when looking over the bot scripts, which are independent of this change, I've put into #101

@ngc92 ngc92 added this to the release 1.2 milestone Feb 27, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant