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

[PR] Speed Up Slow Instances for Lockstep #300

Merged
merged 6 commits into from
Jan 26, 2022

Conversation

JLaferri
Copy link
Member

A very important part of rollback netcode is to ensure both players are playing on roughly the same frame at the same time. This can be somewhat challenging because the games may not start at the exact same time and two computers may not run the game at exactly the same speed. If we don't make sure players are playing on roughly the same frame, you end up with situations of really bad one-sided rollbacks.

We use ACKs to estimate delay time/ping in order to estimate what frame our opponent is on. This has always been the case in Slippi.

What this PR does is it changes how we react to being offset from our opponent.

Previously the player that was ahead would stall on maximum one frame every 30 frames in order to slow down and let the opponent catch up. This was problematic because it only really let us slow down to 58 fps which means if someone was running slower than that for a bit, they would never catch up, causing longer stalls for the person ahead and extremely bad one sided rollbacks. This method would also punish the person with the computer that was fast enough to run the game, stalls can cause a missed input if the timing is really bad. Generally one frame is mostly not noticeable but it's still not ideal.

The new method instead tries to speed up the person running the game slower by doubling frames. It can do this a maximum of 10 times per 60 frames, allowing for the person running slow to catch up faster than previously. Worth noting that doubled frames can mess up timings and cause doubled inputs but at least now we're punishing the person who can't run the game full speed.

Potential future optimizations:
We could try live-tweaking emulation speed in order to sync up the run speed for both players. This could possibly make it so we can time-sync more accurately so both players are running on exactly the same frame and also prevent doubled frames in order to re-sync periodically. One example: on a good connection, I was forced to re-sync once every 47 seconds because my computer was running the game slightly slower than my opponent. In other words, my computer would drift by about one frame every 47 seconds.

@NikhilNarayana NikhilNarayana force-pushed the feature/advance-slow-instance branch from 99cd47c to fc6e404 Compare January 26, 2022 07:19
@NikhilNarayana NikhilNarayana merged commit 248c5f9 into slippi Jan 26, 2022
@NikhilNarayana NikhilNarayana deleted the feature/advance-slow-instance branch October 5, 2023 06:01
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.

2 participants