google / google/codeworld

Could use better time synchronization for game API

Open
#431 3 comments 0 reactions 0 assignees View on GitHub
enhancement
Dominant language
Haskell
Stars
1.3k
Forks
201
PR merge metrics
No merged PRs in 30d

Description

Currently, game clients are synchronized relative to the moment they receive the "game started" message from the game server. If that one packet is delayed (by a TCP drop and retransmit, for example), a client will persistently remain behind the others in time. That means other clients will appear jerky, as they keep going back to add events in the more distant past, then replaying their own events from that point. In fairness terms, the lagged client gets an unfair advantage, as it receives other players' events in the future before they actually occur, but other clients don't see its own events until well after they occur.

To fix this, we should add some kind of NTP-like time management code to revise each client's current timestamp toward a consistent value regardless of any original discrepancy. (But keep in mind that it's critical for correctness that time is monotonic, so we can never decrease a client's timestamp; only slow its rate of increase to allow other clients to catch up.)

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.