lint spawns node --check for 49 files one after another (about 10 s on Windows)

Đang mở Phù hợp với người mới
#261 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ó
2/5
Thời gian dự kiến
1-3 giờ
Mức phù hợp với người mới
82/100
Loại issue
Tái cấu trúc
Độ rõ ràng
Đặc tả rõ ràng
Mức độ hoạt động
Sôi nổi
Công nghệ
javascript, node.js
Lĩnh vực
performance, tooling

Hướng nghiên cứu

Bắt đầu với site/lint.mjs:69-80, đặc biệt là lời gọi execFileSync ở dòng 73, và đọc cách các tệp script được thu thập cũng như cách lỗi được báo cáo. Chạy npm run -s lint để đo thời gian hiện tại, sau đó dùng npm test để kiểm tra hành vi. Công việc hoàn tất khi các bước kiểm tra chạy đồng thời với một pool có giới hạn là os.availableParallelism(), lỗi vẫn theo thứ tự tệp và lint nhanh hơn đáng kể trên máy đa lõi.

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

Mô tả

good first issue performance priority: low

Summary

lint.mjs runs a blocking node --check subprocess per script file in sequence, which makes it the slowest step of npm run check.

Where

  • site/lint.mjs:69-80 (the execFileSync(process.execPath, ["--check", file]) call at :73)

Details

Measured on a Windows dev machine: npm run -s lint 10.8 s vs test 5.1 s, validate 4.8 s, check-added 4.5 s. A single node --check is about 400 ms there; on Linux CI it is about 40-60 ms per file. Cost grows linearly with the number of scripts.

Impact

About a third of every local npm run check, and a smaller share of each CI run.

Steps to reproduce

  1. Time npm run -s lint.
  2. Time node --check site/build.mjs in the same shell and multiply by 49.

Suggested fix

Run the checks in parallel with promisified execFile and a pool capped at os.availableParallelism(), then report errors in file order. Behaviour stays identical.

Acceptance criteria

  • Same errors in the same order
  • Lint wall time drops substantially on a multi-core machine

Getting started

  • Relevant files: site/lint.mjs
  • Run the tests: npm test; the full local gate is npm run check (Node 22+, no install step)
  • Related docs: CONTRIBUTING.md, site/README.md

Filed by repo-audit/full-audit at 4adb944. Severity: low. Effort: S. audit-key: performance|site/lint.mjs|scriptFiles-check

Ngôn ngữ chính
JavaScript
Star
58
Fork
15
Merge trung bình
1 ngày 15 giờ
Pull request đã merge (30 ngày)
12

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 TMHSDigital/Free-Game-Dev-Assets

Tất cả issue của TMHSDigital/Free-Game-Dev-Assets

Issue tương tự

Thêm issue về JavaScript

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.