perf(linter/plugins): grow Uint32Arrays by doubling#20510
Closed
Conversation
This was referenced Mar 19, 2026
This was referenced Mar 19, 2026
This was referenced Mar 19, 2026
Member
Author
Contributor
There was a problem hiding this comment.
Pull request overview
This PR improves performance of oxlint’s JS-side token/comment buffering by reducing the number of Uint32Array reallocations when buffers need to grow, using a doubling strategy with small minimum capacities (similar to Rust’s Vec growth).
Changes:
- Add minimum-capacity constants for several reusable
Uint32Arraybackings. - Change growth strategy for merged tokens+comments backing buffer to allocate at least a minimum on first allocation and double on subsequent growth.
- Change token/comment “deserialized index tracking” arrays to grow-on-demand (doubling) instead of re-allocating per file.
Reviewed changes
Copilot reviewed 3 out of 3 changed files in this pull request and generated 3 comments.
| File | Description |
|---|---|
| apps/oxlint/src-js/plugins/tokens_and_comments.ts | Add a minimum capacity and switch to doubling growth for the merged backing buffer. |
| apps/oxlint/src-js/plugins/tokens.ts | Add min capacity and doubling growth for deserializedTokenIndexes to reduce repeated allocations. |
| apps/oxlint/src-js/plugins/comments.ts | Add min capacity and doubling growth for deserializedCommentIndexes to reduce repeated allocations. |
e20a6c3 to
e08fd3f
Compare
e08fd3f to
3ac4b1e
Compare
3b2206a to
6f6dda2
Compare
Member
Author
Merge activity
|
Member
Author
|
Have folded this into other PRs now. |
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.

deserializedTokenIndexes,deserializedCommentIndexes, andtokensAndCommentsBackingUint32are allUint32Arrays which grow on demand. To avoid frequent allocations, double their size when they have to grow (like Rust'sVec), and with reasonable minimum capacities.