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

未關閉 適合新手
#261 0 則留言 0 個 reaction 已指派 0 人 在 GitHub 檢視

維護者通常 1 天內回覆

還沒有人認領這個 Issue。

評估

難度
2/5
預估耗時
1-3 小時
新手友好度
82/100
Issue 類型
重構
描述清晰度
描述清楚
活躍度
活躍
技術堆疊
javascript, node.js

研究方向

從 site/lint.mjs:69-80 開始,特別是第 73 行的 execFileSync 呼叫,並了解腳本檔案如何收集以及錯誤如何回報。執行 npm run -s lint 測量目前耗時,接著用 npm test 檢查行為。完成條件是:檢查使用上限為 os.availableParallelism() 的池並行執行,錯誤仍依檔案順序排列,而且 lint 在多核心機器上明顯加快。

由索引模型根據 Issue 內容生成。

描述

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

主要語言
JavaScript
星號
58
分支
15
平均合併
1 天 15 小時
30 天內合併 PR
12

環境準備

從這裡開始

  1. 先讀完整個 Issue,再讀專案的貢獻指南。
  2. 在 Issue 下留言說明你要接手 —— 這能避免兩個人做同樣的事。
  3. Fork 儲存庫,在一個分支上完成修改。
  4. 送出 Pull Request,並在描述裡引用這個 Issue 編號。

TMHSDigital/Free-Game-Dev-Assets 的其他 Issue

查看 TMHSDigital/Free-Game-Dev-Assets 的全部 Issue

相似的 Issue

更多 JavaScript Issue

把新 issue 寄到你的電子郵件信箱

精選適合新手參與的 GitHub issue 摘要。