perf(linter/plugins): move creating merger functions off hot path#20314
perf(linter/plugins): move creating merger functions off hot path#20314overlookmotel wants to merge 1 commit intomainfrom
Conversation
How to use the Graphite Merge QueueAdd either label to this PR to merge it via 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. |
There was a problem hiding this comment.
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.
| // 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)); |
There was a problem hiding this comment.
Yeah, I've re-thought this. #20319 takes a different approach.
|
Closing in favour of #20319. |

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.