Skip to content

perf(batch-lint): bound getMaxFileSize stat concurrency to 128#82

Merged
luojiyin1987 merged 2 commits into
masterfrom
fix/issue-80-getmaxfilesize-concurrency-limit
Jul 9, 2026
Merged

perf(batch-lint): bound getMaxFileSize stat concurrency to 128#82
luojiyin1987 merged 2 commits into
masterfrom
fix/issue-80-getmaxfilesize-concurrency-limit

Conversation

@luojiyin1987

@luojiyin1987 luojiyin1987 commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

Summary

  • getMaxFileSize no longer issues an unbounded Promise.all over every file. It now reuses runTasksWithLimit with a new STAT_CONCURRENCY_LIMIT = 128 constant, so very large repositories no longer hit an N-fd filesystem stat burst.
  • Real max-size semantics, empty-list → 0, and reject-on-stat-failure behavior are all preserved (only the in-flight stat count is bounded).
  • Updated the misleading TODO(perf, #78) comment to reference [cli] getMaxFileSize: chunk stat calls or short-circuit on huge files #80, and added inline comments explaining the design tradeoff.

Why throttling instead of short-circuiting

We chose bounded concurrency (#1) over the short-circuit variant (#2). getMaxFileSize() must keep returning the true maximum file size: src/lint-md.ts (line #131) logs max file ${maxMiB} MiB in --threads auto --dev mode, and an early return on a 5 MiB hit would make both the returned max and the log inaccurate when a larger file follows. Throttling caps only the filesystem burst and leaves external behavior identical. STAT_CONCURRENCY_LIMIT = 128 is an empirical pick (the issue itself suggests 64/128 as examples), not a benchmark-derived value — the goal is an upper bound, not a tuned constant.

Scope / non-goals

  • Only affects --threads auto (the only path that calls getMaxFileSize).
  • Does NOT touch resolveAdaptiveConcurrency's threshold table, the cpuLimit computation, runTasksWithLimit itself, the numeric --threads N path, or the worker pool size.

Test plan

  • Added a unit test that mocks fs/promises.stat with a delay and asserts concurrent stat calls stay <= STAT_CONCURRENCY_LIMIT while still returning the true max.
  • npm test (75 passed) and npm run lint are green.

Closes #80

🤖 Generated with opencode

getMaxFileSize no longer issues an unbounded Promise.all over every
file. It reuses runTasksWithLimit with STAT_CONCURRENCY_LIMIT (128) so
very large repositories no longer hit an N-fd stat burst. Real max
size semantics, empty-list and reject-on-failure behavior are unchanged.
Closes #80.
…ort-circuits

Add inline comments on STAT_CONCURRENCY_LIMIT and getMaxFileSize explaining
the tradeoff: concurrency is bounded (not short-circuited) so the function
keeps returning the true max size consumed by the --threads auto --dev log.
Clarifies #80.
@luojiyin1987 luojiyin1987 merged commit ee46f53 into master Jul 9, 2026
5 checks passed
@luojiyin1987 luojiyin1987 deleted the fix/issue-80-getmaxfilesize-concurrency-limit branch July 9, 2026 01:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[cli] getMaxFileSize: chunk stat calls or short-circuit on huge files

1 participant