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 类型
重构
描述清晰度
描述清楚
活跃度
活跃

调研方向

从 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 摘要。