Skip to content

perf(linter/plugins): pre-populate cache of EnterExit objects#20187

Merged
graphite-app[bot] merged 1 commit intomainfrom
om/03-10-perf_linter_plugins_pre-populate_cache_of_enterexit_objects
Mar 10, 2026
Merged

perf(linter/plugins): pre-populate cache of EnterExit objects#20187
graphite-app[bot] merged 1 commit intomainfrom
om/03-10-perf_linter_plugins_pre-populate_cache_of_enterexit_objects

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 10, 2026

Perf optimization to visitor compilation.

Previously in the main loop for non-leaf visitors in finalizeCompiledVisitor, every turn of the loop had to check if cache contains an EnterExit object it can reuse, and to create a new one if not.

Instead, pre-populate the cache of EnterExit object before that main loop, to ensure there are always enough in the main loop.

After warmup over the first few files, the cache will be populated with enough EnterExit objects to service every file, and the "populate" loop will be skipped entirely.

This converts what was 1 branch per loop iteration to 1 highly predictable branch per file.

Copy link
Member Author

overlookmotel commented Mar 10, 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 C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 10, 2026
@overlookmotel overlookmotel marked this pull request as ready for review March 10, 2026 10:46
@overlookmotel overlookmotel requested a review from camc314 as a code owner March 10, 2026 10:46
Copilot AI review requested due to automatic review settings March 10, 2026 10:46
@overlookmotel overlookmotel self-assigned this Mar 10, 2026
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 JS visitor compilation in apps/oxlint by ensuring the EnterExit object cache is pre-sized before the main non-leaf merge loop, reducing per-iteration branching in a hot path.

Changes:

  • Replace enterExitObjectCacheNextIndex with activeNonLeafVisitorsCount to track how many cached EnterExit objects are in use.
  • Pre-populate enterExitObjectCache up front in finalizeCompiledVisitor, then index directly into the cache during merging.
  • Update resetCompiledVisitor to clear only the EnterExit objects used by the last compilation.

@overlookmotel overlookmotel force-pushed the om/03-10-perf_linter_plugins_pre-populate_cache_of_enterexit_objects branch from a49e3e4 to f32b86c Compare March 10, 2026 11:24
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 10, 2026
@graphite-app
Copy link
Contributor

graphite-app bot commented Mar 10, 2026

Merge activity

Perf optimization to visitor compilation.

Previously in the main loop for non-leaf visitors in `finalizeCompiledVisitor`, every turn of the loop had to check if cache contains an `EnterExit` object it can reuse, and to create a new one if not.

Instead, pre-populate the cache of `EnterExit` object *before* that main loop, to ensure there are always enough in the main loop.

After warmup over the first few files, the cache will be populated with enough `EnterExit` objects to service every file, and the "populate" loop will be skipped entirely.

This converts what was 1 branch per loop iteration to 1 highly predictable branch per file.
@graphite-app graphite-app bot force-pushed the om/03-09-perf_linter_plugins_free_visit_functions_earlier branch from 8a74e77 to c73912b Compare March 10, 2026 11:48
@graphite-app graphite-app bot force-pushed the om/03-10-perf_linter_plugins_pre-populate_cache_of_enterexit_objects branch from f32b86c to 3061acb Compare March 10, 2026 11:49
graphite-app bot pushed a commit that referenced this pull request Mar 10, 2026
Perf optimization to visitor compilation.

Apply the same optimization as #20187 to the cache of `VisitProp` objects.

Instead of main loop in `addVisitorToCompiled` checking on each turn of the loop whether cache contains a `VisitProp` object it can reuse, instead pre-populate the cache to ensure it always does.
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Mar 10, 2026
Base automatically changed from om/03-09-perf_linter_plugins_free_visit_functions_earlier to main March 10, 2026 12:00
@graphite-app graphite-app bot merged commit 3061acb into main Mar 10, 2026
20 checks passed
@graphite-app graphite-app bot deleted the om/03-10-perf_linter_plugins_pre-populate_cache_of_enterexit_objects branch March 10, 2026 12:01
graphite-app bot pushed a commit that referenced this pull request Mar 10, 2026
…artup (#20194)

Perf optimization to visitor compilation. Continuation of #20187.

Instead of populating the cache of `EnterExit` objects in `finalizeCompiledVisitor`, populate it in full at process startup.

The main gain is that it makes these objects, which are heavily accessed during AST walk, more likely to be grouped together in memory, reducing L1 cache misses, and consuming less L1 cache.
leaysgur added a commit that referenced this pull request Mar 11, 2026
# Oxlint
### 🚀 Features

- 04a5ce0 oxlint: Support `vite.config.ts` `.lint` field (#20214)
(leaysgur)
- 1735215 linter: Implement `react/no-clone-element` rule. (#20129)
(connorshea)
- 68e6f6f linter: Implement `react/no-react-children` rule. (#20104)
(connorshea)
- fe3b32e linter/plugins: Add `oxlint-plugin-eslint` package (#20009)
(overlookmotel)

### 🐛 Bug Fixes

- 05f6a09 linter/no-inline-comments: Deserialize rule options with serde
(#20207) (camc314)
- c7eb09d linter/default-case: Deserialize rule options with serde
(#20206) (camc314)
- f85e16c linter/plugins: Fix types for visitor compilation (#20203)
(overlookmotel)
- 44e24e0 linter/exhaustive-deps: Ignore type-only typeof deps (#20201)
(camc314)
- 0b04998 linter/no-fallthrough: Deserialize rule options with serde
(#20192) (camc314)
- a1031cb linter/new-cap: Deserialize rule options with serde (#20161)
(camc314)
- ad27fd6 linter: Add help messages to import plugin diagnostics
(#20158) (John Costa)
- 1340307 linter/plugins: Ensure `after` hooks always run (#20167)
(overlookmotel)
- c4812ec linter/plugins: Reset visitor compilation state if error
during compilation (#20166) (overlookmotel)
- 887eecc linter/plugins: Add license notice to `oxlint-plugin-eslint`
package (#20164) (overlookmotel)
- e1713a4 linter/plugins: Include common chunks in
`oxlint-plugin-eslint` package (#20163) (overlookmotel)
- a9acb2b linter: Check `globals` entry for `no-undef`, only check
es2026 globals for `no-extend-native` and
`no-constant-binary-expression` (#20089) (Sysix)
- 5559f0d linter/no-unused-vars: `reportUsedIgnorePattern` should not
report used rest siblings (#20108) (Don Isaac)
- de7c0e2 linter/plugins: Correct error message for `markVariableAsUsed`
(#20152) (overlookmotel)

### ⚡ Performance

- 3a86427 linter/plugins: Pre-populate cache of `EnterExit` objects at
startup (#20194) (overlookmotel)
- d243391 linter/plugins: Replace arrays with `Uint8Array`s (#20190)
(overlookmotel)
- 8742f8b linter/plugins: Pre-populate cache of `VisitProp` objects
(#20189) (overlookmotel)
- 3061acb linter/plugins: Pre-populate cache of `EnterExit` objects
(#20187) (overlookmotel)
- c73912b linter/plugins: Free visit functions earlier (#20186)
(overlookmotel)
- d9f8ff4 linter/plugins: Faster reset of visitor state (#20185)
(overlookmotel)
- 42aff15 oxlint/lsp: Avoid computing diagnostics for non invoked code
actions requests (#20080) (Sysix)

### 📚 Documentation

- a080650 linter/plugins: Fix documentation of visitor compilation
(#20202) (overlookmotel)
- 542a04a linter: Add a link to the cyclomatic complexity Wikipedia
article in `eslint/complexity` (#20174) (connorshea)
# Oxfmt
### 🚀 Features

- 95943aa oxfmt: Support `vite.config.*` `.fmt` field (#20197)
(leaysgur)
- 172fc07 oxfmt: .js/.ts config file support (#20135) (leaysgur)

### 🐛 Bug Fixes

- e483569 oxfmt: Avoid double-escaping in css-in-js (#20211) (leaysgur)

Co-authored-by: leaysgur <6259812+leaysgur@users.noreply.github.com>
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