perf(linter/plugins): recycle Location objects#20491
Merged
graphite-app[bot] merged 1 commit intomainfrom Mar 21, 2026
Merged
Conversation
This was referenced Mar 18, 2026
Member
Author
8f03505 to
733bd17
Compare
5c85a67 to
cea62d4
Compare
133b026 to
495ab73
Compare
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reduces GC pressure during linting by introducing an object pool for Location (and its nested LineColumn) instances, recycling them across files instead of allocating new objects as loc is accessed.
Changes:
- Added a
Locationobject pool inlocation.tsand updatedcomputeLoc()to reuse pooled objects. - Renamed the per-file cleanup hook from
resetLines()toresetLinesAndLocs()and reset theLocationpool alongside line caches. - Updated
SourceCodereset flow to call the new combined reset function.
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/source_code.ts | Switches reset logic to resetLinesAndLocs() so Location pooling is reset per file. |
| apps/oxlint/src-js/plugins/location.ts | Implements Location pooling and refactors line/column computation to populate existing objects. |
495ab73 to
e627943
Compare
This was referenced Mar 18, 2026
Contributor
There was a problem hiding this comment.
Pull request overview
This PR introduces pooling for Location objects used by the linter’s JS-side SourceCode/AST/token/comment location APIs, to reduce per-file allocations and GC overhead during linting runs.
Changes:
- Add a
Locationobject pool inlocation.ts(reusingLocation+ nestedLineColumnobjects across files). - Replace
resetLines()withresetLinesAndLocs()and wire it into the per-file reset path. - Refactor line/column computation to populate pre-existing
LineColumnobjects (supporting pooledLocationinstances).
Reviewed changes
Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/source_code.ts | Switch per-file reset to resetLinesAndLocs() so line tables and the Location pool are reset together. |
| apps/oxlint/src-js/plugins/location.ts | Implement Location pooling and update line/column helpers to populate objects in place. |
This was referenced Mar 19, 2026
cea62d4 to
7de6e14
Compare
e627943 to
48e7129
Compare
7de6e14 to
2be5b0a
Compare
48e7129 to
24da144
Compare
Contributor
Merge activity
|
Add an object pool for `Location` objects, and recycle them across files. Usually, only a minority of AST nodes, tokens, and comments will have their `loc` property accessed, so the pool is not pre-populated - `Location` objects are only created on demand. Like the other object pools, once warmed up over the first batch of files, the fast path for "use an existing object from the pool" will be consistently taken and no further objects will be allocated. All `Location` objects will soon graduate to "old space" where they don't impede or trigger minor GC.
2be5b0a to
8729614
Compare
24da144 to
5984a66
Compare
Base automatically changed from
om/03-18-perf_linter_plugins_reduce_operations_in_binary_search
to
main
March 21, 2026 12:52
This was referenced Mar 23, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.

Add an object pool for
Locationobjects, and recycle them across files.Usually, only a minority of AST nodes, tokens, and comments will have their
locproperty accessed, so the pool is not pre-populated -Locationobjects are only created on demand.Like the other object pools, once warmed up over the first batch of files, the fast path for "use an existing object from the pool" will be consistently taken and no further objects will be allocated. All
Locationobjects will soon graduate to "old space" where they don't impede or trigger minor GC.