Skip to content

perf(linter): compute apply_overrides rule set lazily#23648

Open
shulaoda wants to merge 1 commit into
oxc-project:mainfrom
shulaoda:06-19-perf_apply_overrides_lazy_rules
Open

perf(linter): compute apply_overrides rule set lazily#23648
shulaoda wants to merge 1 commit into
oxc-project:mainfrom
shulaoda:06-19-perf_apply_overrides_lazy_rules

Conversation

@shulaoda

Copy link
Copy Markdown
Contributor

Config::apply_overrides is called for every linted file. It eagerly built all_rules by filtering and cloning every entry in RULES (~837 rules) into a Vec on each call.

But all_rules is only used when an override introduces a new, unconfigured plugin (to apply that plugin's category rules). In the common case — overrides that only tweak rule severities for certain file globs — it was computed and never used, cloning ~837 rules per file for nothing.

This computes all_rules lazily (Option<Vec<RuleEnum>> + get_or_insert_with), so it is only built when a new plugin actually requires it, and reused across override iterations exactly as before. Behavior is unchanged.

Both code paths are covered by existing tests: the common path (test_remove_rule, test_change_rule_severity, …) and the lazy path (test_categories_only_applied_to_new_plugins_not_in_root, test_categories_not_reapplied_to_root_plugins, …).

@shulaoda shulaoda requested a review from camc314 as a code owner June 19, 2026 13:29
@codspeed-hq

codspeed-hq Bot commented Jun 19, 2026

Copy link
Copy Markdown

Merging this PR will not alter performance

✅ 5 untouched benchmarks
⏩ 66 skipped benchmarks1


Comparing shulaoda:06-19-perf_apply_overrides_lazy_rules (d09e3c4) with main (b1948a1)

Open in CodSpeed

Footnotes

  1. 66 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@camc314 camc314 added the A-linter Area - Linter label Jun 19, 2026
@camc314 camc314 self-assigned this Jun 19, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants