perf(network): repeated copies and allocations in the packet send and receive paths

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
4/5
見積もり時間
3〜5日
初心者へのやさしさ
53/100
issue の種類
機能追加
明瞭さ
おおむね明確
活発さ
活発
技術スタック
typescript
領域
networking

調査の方向性

Start with the five listed locations in modules/network/src/shared/channels.ts, modules/network/src/server/utils.ts, modules/network/src/server/network-server.ts, modules/network/src/shared/packet.ts, and modules/network/src/server/peer-host.ts; trace how packet buffers and per-tick containers move through send, receive, and dispatch. The issue identifies the repeated copies and allocations to address. Done when those paths avoid the described unnecessary copies and rebuilds while packet results remain correct; the issue names no tests to run.

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

説明

enhancement modules:network
Which package or utils is this feature request for?

network

Feature

TCP receive copies each frame twice (rawDataToUint8Array, then slice(1)), send copies it twice, and PeerHost.send copies it for each recipient. getReceivedPackets() rebuilds arrays each tick, and dispatch spreads the listener set. Results are correct, but this is garbage on every packet and tick.

Where:

Evidence:

return { channel, data: frame.slice(1) };
merged.set(clientId, [...(merged.get(clientId) ?? []), ...packets]);
for (const listener of [...listeners]) this.call(listener, received, ctx);
Ideal solution or implementation

Use subarray(1) on frames the code owns, skip copies of inputs that are already Uint8Array, and reuse containers between ticks.

Alternative solutions or implementations

No response

Other context

Found during a code audit of main at be72076.

主要言語
TypeScript
スター
7
フォーク
2
平均マージ
1日 17時間
マージ済み PR(30日)
17

環境構築

はじめの一歩

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

NanoForge-dev/Engine のほかの issue

NanoForge-dev/Engine の issue をすべて見る

似ている issue

TypeScript の issue をもっと見る

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

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