perf(batch): avoid retaining clean fix results - #188
Merged
Merged
Conversation
- Add CompactFixedResult type (Pick<FixedResult, 'metrics' | 'convergence'>) - Project clean fix items in worker before cross-thread return - Add isFullFixedResult type guard for narrowing - Add benchmark script for RSS comparison Benchmark results (1000 files × 64 KiB, --fix --threads 4): baseline: 1500.9 MiB avg peak RSS compact: 1436.0 MiB avg peak RSS delta: -64.9 MiB (4.3%) Benchmark results (5000 files × 64 KiB, --fix --threads 4): baseline: 1852.7 MiB avg peak RSS compact: 1515.5 MiB avg peak RSS delta: -337.2 MiB (18.2%)
luojiyin1987
added a commit
that referenced
this pull request
Sep 13, 2026
This reverts commit 1478ce0.
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.
Problem
In fix mode,
batchLint()accumulates fullBatchLintItemresults includingfixedResult.result(the complete fixed Markdown text) for ALL files, even clean ones. TheallResultsarray is only consumed bygetFixDevMetrics()which only needspath,fixedResult.metrics, andfixedResult.convergence.This causes unbounded memory growth proportional to total input size:
Example: 10k clean files × 1 MiB each → ~10 GiB retained in
allResults.Solution
Project clean fix items in the worker to a compact form before returning across the thread boundary. The full Markdown text is never structured-cloned back to the main thread for files that don't need writing.
Changes
src/types.ts— AddCompactFixedResultinterface andisFullFixedResulttype guardsrc/utils/lint-worker.ts— Project clean items to compact form (onlymetrics/convergence)src/cli/run-lint.ts— Use type guard in write pathCloses #187