khemssharma / khemssharma/Chess

Per-game 100ms clock timers add up at scale

Open
#76 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

backend enhancement good first issue help wanted performance
Dominant language
TypeScript
Stars
29
Forks
2
Avg merge
2m
Merged PRs (30d)
5

Description

Summary

For every game with a time control, Game.ts runs setInterval(..., 100)
to push clock updates (TIME_UPDATE) to both players. At scale this is
system-wide overhead that grows linearly with concurrent timed games:
500 timed games = 5,000 timer callbacks/sec, each doing 2 JSON.stringify

  • 2 ws.send().

Note

Load tests in load-tests/ws-load-test.ts currently use timeControl: null
specifically to isolate this cost from the matchmaking/routing cost
Real-world games are mostly timed, so this cost is additive on top of what
was measured.

Proposed direction

Replace per-game intervals with a single shared ticking loop (e.g. one
setInterval that iterates active timed games and only sends updates that
actually changed, or batches multiple games' updates per tick). This changes
timing precision slightly, so worth confirming acceptable drift before
implementing.

Contributor guide

No contributing guide indexed for this repository

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start in Game.ts by tracing the per-game setInterval that sends TIME_UPDATE to both players, then review load-tests/ws-load-test.ts to understand the current workload assumptions. Replace the per-game timers with a shared approach, and confirm that timing drift remains acceptable while reducing timer and message overhead for concurrent timed games.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
backend, performance
Issue type
Refactor
Difficulty
4/5
Estimated time
3-5 days
Activity status
Quiet
Clarity
Mostly clear
Newbie friendliness
52/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.