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

Đang mở
#507 0 bình luận 0 reaction 0 người được giao Xem trên GitHub

Maintainer thường phản hồi trong vòng 1 ngày

Chưa có ai nhận issue này.

Đánh giá

Độ khó
4/5
Thời gian dự kiến
3-5 ngày
Mức phù hợp với người mới
53/100
Loại issue
Tính năng
Độ rõ ràng
Khá rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
typescript
Lĩnh vực
networking

Hướng nghiên cứu

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.

Do mô hình lập chỉ mục viết ra từ nội dung của issue.

Mô tả

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.

Ngôn ngữ chính
TypeScript
Star
7
Fork
2
Merge trung bình
1 ngày 17 giờ
Pull request đã merge (30 ngày)
17

Chuẩn bị môi trường

Bắt đầu từ đâu

  1. Đọc hết issue, rồi đọc hướng dẫn đóng góp của dự án.
  2. Bình luận trên issue rằng bạn sẽ nhận — tránh hai người làm cùng một việc.
  3. Fork repository và làm thay đổi trên một nhánh.
  4. Mở pull request có tham chiếu số hiệu của issue.

Issue khác của NanoForge-dev/Engine

Tất cả issue của NanoForge-dev/Engine

Issue tương tự

Thêm issue về TypeScript

Nhận issue mới trong hộp thư của bạn

Bản tóm tắt ngắn những issue GitHub phù hợp với người mới.