perf(linter/import/no-cycle): skip the graph walk for acyclic modules #25003
All Vouch review confidence checks passed
Residual risk 0.24 = Change Risk (0.55) × (1 − Review Confidence (0.57)).
Review depth and reviewer attention state are adequate.
Model 1 · Change Risk (XGBoost)
Score: 0.55 · 630 lines diff across 7 files
Model 2 · Review Depth (DistilBERT)
Depth Score: 0.17 · 1 substantive comment(s)
Model 3 · Review Timing & Attention
Session adequacy: 100% · Reviewer familiarity: 35%
Bedrock Claude 3 · Risk Narration
(disconnected)
Groq Risk Narration
AWS Bedrock is currently disconnected. Generate high-confidence PR triage narration on-demand using Groq.
Model 1 · Change Risk Attribution
SHAP Weights
Diff Size
diff_size
0.386
Shallow Review Depth
shallow_review_depth
0.289
Ai Authored
ai_authored
0.050
Real PR Conversation Timeline
1 comments
"Review active on #25003"
general
weight: 0.35
connorshea
This is the change from #24963, but as its own PR to avoid dependency on the larger refactor PR it was targeted at. Benchmarks have been re-run to ensure that the info is correct, but I'm pretty confident in this change now.
AI Disclosure: Generated with Claude Code, Opus 5. Reviewed and tested manually be me.
What
run_oncewalks the module graph once per direct import, and each walk explores the module's whole reachable subgraph before concluding "no cycle". Onvscode/srcthat is 78,760 walks producing 1,566 diagnostics, so 98% of them are pure overhead.A module is in a cycle if and only if some module reachable from it imports it back. So one traversal of that subgraph answers the question for every direct import at once. When it says no, skip all the walks.
Why it can't change what's reported
The prefilter only gates the walks — they still decide what is reported and reconstruct the cycle path for the diagnostic. It cannot skip a cycle a walk would have found:
should_traverse_modulefilter;max_depth, so its reachable set is a strict superset;Arcidentity, matching what the walks report a cycle on — a file split into multiple sections has one record per section but one path.It runs only under the default unbounded
max_depth, where the walks cover the whole subgraph anyway and the prefilter replaces work rather than adding to it. With a smallmax_depththe walks are shallow enough that an unbounded prefilter could cost more than it saves, so behaviour there is exactly as before.Measurements
vscode/src— 7,368 files, 81,512 direct imports, 78,760 walks — withimport/no-cycleas the only enabled rule (number_of_rules: 1). Paired interleaved runs with per-round order alternation, n=15,--silent, release builds with--features allocator.Wall clock
| | mean | sd |
| --------------------- | --------- | -------- |
|
main| 3217.3 ms | 169.3 ms || this PR | 1178.3 ms | 56.1 ms |
| paired delta | −2038.9 ms | 127.6 ms |
t = +61.9, faster in 15/15 paired rounds. Subtracting the parse-only baseline, rule-attributable time goes 3110.5 ms → 1073.3 ms, 2.9× faster.
The parse-only control (same binaries, no rules enabled) is flat — 106.8 ms vs 105.0 ms, paired delta +1.8 ms, t = +0.49 — so the delta is attributable to the rule and not to binary layout or the harness.
Allocations
Counted with a global-allocator shim; rule-attributable = total minus a parse-only run on the same binary.
| | allocations | bytes |
| ------- | ----------- | -------- |
|
main| 331.0M | 22.52 GB || this PR | 86.8M | 6.05 GB |
| | −73.8% | −73.1% |
Counts are stable to within 0.05% across repetitions, and the two parse-only baselines (separately built binaries) agree to 0.003%, which is what makes that subtraction meaningful.
Correctness
main, 1,566 on this branch, identical after sorting by(filename, labels, message, code).oxc_lintertest suite passes (1,175 tests) with no snapshot changes;cargo clippy -p oxc_linter --all-features --all-targets -D warningsis clean.Cross-codebase parity
Both binaries were also run over five TypeScript codebases, under the default options plus two variants chosen to stress what is most likely to break:
ignoreTypes: falsechanges which edgesshould_traverse_moduleadmits, so the prefilter has to apply the identical filter, andmaxDepth: 5disables the prefilter entirely.| codebase | files | config |
main| this PR | identical || --- | --- | --- | --- | --- | --- |
| vscode | 11,674 | default | 2,789 | 2,789 | ✅ |
| actualbudget/actual | 1,789 | default | 188 | 188 | ✅ |
| actualbudget/actual | 1,789 |
ignoreTypes: false| 591 | 591 | ✅ || actualbudget/actual | 1,789 |
maxDepth: 5| 47 | 47 | ✅ || storybook | 4,050 | default | 96 | 96 | ✅ |
| storybook | 4,050 |
ignoreTypes: false| 430 | 430 | ✅ || storybook | 4,050 |
maxDepth: 5| 40 | 40 | ✅ || rolldown | 6,411 | default | 77 | 77 | ✅ |
| rolldown | 6,411 |
ignoreTypes: false| 239 | 239 | ✅ || rolldown | 6,411 |
maxDepth: 5| 73 | 73 | ✅ || microsoft/TypeScript | 39,333 | default | 729 | 729 | ✅ |
| microsoft/TypeScript | 39,333 |
ignoreTypes: false| 729 | 729 | ✅ || microsoft/TypeScript | 39,333 |
maxDepth: 5| 242 | 242 | ✅ |Counts are
import(no-cycle)diagnostics. The comparison is stricter than the counts: in all 13 runs the entire diagnostic array is element-wise identical after sorting by(filename, labels, message, code)— including the 30,713 parse errors the TypeScript repo's test fixtures produce — so no diagnostic changed span or cycle path either. These are full repository checkouts, which is why vscode is 11,674 files here rather than the 7,368 measured above.