Skip to content

refactor: share file-level scope analysis across rules - #2164

Merged
fansenze merged 1 commit into
mainfrom
perf/shared-file-scope-cache
Sep 16, 2026
Merged

fansenze merged 1 commit into
mainfrom
perf/shared-file-scope-cache

Conversation

@elecmonkey

Copy link
Copy Markdown
Member

Motivation

Reuse the CachedByFile API previously introduced for the Rstest rule set to avoid constructing equivalent scope graphs multiple times for the same file.

Changes

Centralize reusable scope queries in scopeanalysis and migrate scope consumers to the shared file-level cache. Exact option shapes remain isolated, while complete reference graphs and declaration trees can be safely reused.

Move no-shadow analysis to the end of the file so it can reuse a graph initialized by an earlier rule.

Repository import/order no-use-before-define no-shadow
Rspack 1.10 → 1.10 ms (0.0%) 0.60 → 0.10 ms (-83.3%) 0.40 → 0.10 ms (-75.0%)
Rsbuild 9.85 → 10.45 ms (+6.1%) 3.85 → 0.50 ms (-87.0%) 2.55 → 0.45 ms (-82.4%)
Rslib 2.75 → 3.00 ms (+9.1%) 1.25 → 0.20 ms (-84.0%) 0.70 → 0.10 ms (-85.7%)
Rspress 2.95 → 3.00 ms (+1.7%) 1.50 → 0.20 ms (-86.7%) 0.95 → 0.20 ms (-78.9%)
Rsdoctor 3.00 → 3.00 ms (0.0%) 1.40 → 0.15 ms (-89.3%) 1.00 → 0.20 ms (-80.0%)
Rstest 14.55 → 14.65 ms (+0.7%) 7.75 → 0.80 ms (-89.7%) 5.30 → 1.00 ms (-81.1%)

@elecmonkey
elecmonkey added this pull request to stack #2166 September 15, 2026 08:54
@elecmonkey
elecmonkey marked this pull request as ready for review September 15, 2026 11:53
@fansenze
fansenze merged commit 54712a5 into main Sep 16, 2026
15 checks passed
@fansenze
fansenze deleted the perf/shared-file-scope-cache branch September 16, 2026 04:13
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.

2 participants