perf(ecs): per-frame copies, allocations and WASM crossings in run_systems and the zippers

Đang mở
#493 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
42/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ệ
cpp, wasm
Lĩnh vực
game-dev, performance

Hướng nghiên cứu

Read modules/ecs/wasm/Registry.hpp around lines 260–262 and 302–322 to trace run_systems and getZipper. First establish an e2e game performance measurement, since the issue says none has been taken. Compare the per-frame allocations and WASM crossings before and after the proposed caching and length-read changes; done means measured improvement without changing ECS behavior.

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

Mô tả

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

ecs

Feature

The hottest path breaks the repo's rule against per-frame allocation, at a cost of entities × systems. Every frame copies the systems vector and creates a shared_from_this() JS wrapper per system. Each getZipper builds a std::map, a JS array and one JS object per matching entity, calls get_js_class_name twice per component (3–6 JS property reads each) and re-reads comps["length"] on each iteration. No measurement was taken yet.

Where:

Evidence:

std::vector<emscripten::val> systems_copy = _systems;
for (emscripten::val &system : systems_copy)
    system(shared_from_this(), ctx);
Ideal solution or implementation

Copy the systems only when they change during a run, cache the class-name → array pointer lookup per constructor, and read length once. Measure before and after with the e2e game.

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.