perf(batch-lint): bound getMaxFileSize stat concurrency to 128#82
Merged
luojiyin1987 merged 2 commits intoJul 9, 2026
Merged
Conversation
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.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
getMaxFileSizeno longer issues an unboundedPromise.allover every file. It now reusesrunTasksWithLimitwith a newSTAT_CONCURRENCY_LIMIT = 128constant, so very large repositories no longer hit an N-fd filesystem stat burst.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) logsmax file ${maxMiB} MiBin--threads auto --devmode, 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 = 128is 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
--threads auto(the only path that callsgetMaxFileSize).resolveAdaptiveConcurrency's threshold table, thecpuLimitcomputation,runTasksWithLimititself, the numeric--threads Npath, or the worker pool size.Test plan
fs/promises.statwith a delay and asserts concurrent stat calls stay<= STAT_CONCURRENCY_LIMITwhile still returning the true max.npm test(75 passed) andnpm run lintare green.Closes #80
🤖 Generated with opencode