Per-game 100ms clock timers add up at scale

オープン
#76 コメント 0 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
52/100
issue の種類
リファクタリング
明瞭さ
おおむね明確
活発さ
静か
技術スタック
typescript

調査の方向性

Game.ts から始めて、両プレイヤーに TIME_UPDATE を送信するゲームごとの setInterval を追跡し、次に load-tests/ws-load-test.ts を確認して現在のワークロードの前提を理解します。ゲームごとのタイマーを共有方式に置き換え、同時実行される時間制ゲームにおけるタイマーとメッセージのオーバーヘッドを削減しながら、タイミングのずれが許容範囲内に収まることを確認します。

索引モデルが issue の本文から書いたものです。

説明

backend enhancement good first issue help wanted performance

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.

主要言語
TypeScript
スター
29
フォーク
2
平均マージ
13分
マージ済み PR(30日)
1

環境構築

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

khemssharma/Chess のほかの issue

khemssharma/Chess の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。