Skip to content

perf(linter/plugins): move creating merger functions off hot path#20314

Closed
overlookmotel wants to merge 1 commit intomainfrom
om/03-10-perf_linter_plugins_move_creating_merger_functions_off_hot_path
Closed

perf(linter/plugins): move creating merger functions off hot path#20314
overlookmotel wants to merge 1 commit intomainfrom
om/03-10-perf_linter_plugins_move_creating_merger_functions_off_hot_path

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 13, 2026

When compiling a visitor, visit functions from different rules which act on the same AST node (e.g. Identifier) need to be merged into a single function.

Functions which merge up to 5 visit function are hard-coded. If need to merge 6 or more functions, new merger functions are generated dynamically.

Apply the same optimization as #20187 and #20189 to this process. Pre-populate the stock of merger functions before the main logic. Once warmed up over first few files, there will be enough merger functions ready for use, and the loop will be skipped, leaving only a single, very predictable branch.

Copy link
Member Author

overlookmotel commented Mar 13, 2026


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • 0-merge - adds this PR to the back of the merge queue
  • hotfix - for urgent changes, fast-track this PR to the front of the merge queue

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions bot added A-linter Area - Linter A-cli Area - CLI A-linter-plugins Area - Linter JS plugins labels Mar 13, 2026
@github-actions github-actions bot added the C-performance Category - Solution not expected to change functional behavior, only performance label Mar 13, 2026
@overlookmotel overlookmotel marked this pull request as ready for review March 13, 2026 00:32
@overlookmotel overlookmotel requested a review from camc314 as a code owner March 13, 2026 00:32
Copilot AI review requested due to automatic review settings March 13, 2026 00:32
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Optimizes oxlint’s JS-side visitor compilation by reducing per-merge branching when combining multiple rule handlers for the same AST node (and CFG events), aiming to keep visitor compilation predictable after warm-up.

Changes:

  • Replace “get-or-create specific merger” logic with a warm-up loop that fills merger caches up to the required arity.
  • Apply the same warm-up strategy to both AST visit function mergers and CFG visit function mergers.

Comment on lines +573 to +576
// If no existing merger for `numVisitFns` functions, create mergers for all numbers of functions up to
// and including `numVisitFns`. After warm-up over first few files, this loop will be skipped.
while (mergers.length <= numVisitFns) {
mergers.push(createMerger(mergers.length));
Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah, I've re-thought this. #20319 takes a different approach.

@overlookmotel overlookmotel self-assigned this Mar 13, 2026
@overlookmotel
Copy link
Member Author

Closing in favour of #20319.

@overlookmotel overlookmotel deleted the om/03-10-perf_linter_plugins_move_creating_merger_functions_off_hot_path branch March 13, 2026 01:23
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-cli Area - CLI A-linter Area - Linter A-linter-plugins Area - Linter JS plugins C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants