Skip to content

perf(linter/plugins): grow Uint32Arrays by doubling#20510

Closed
overlookmotel wants to merge 1 commit intoom/03-18-perf_linter_plugins_share_empty_uint32array_across_multiple_placesfrom
om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling
Closed

perf(linter/plugins): grow Uint32Arrays by doubling#20510
overlookmotel wants to merge 1 commit intoom/03-18-perf_linter_plugins_share_empty_uint32array_across_multiple_placesfrom
om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 19, 2026

deserializedTokenIndexes, deserializedCommentIndexes , and tokensAndCommentsBackingUint32 are all Uint32Arrays which grow on demand. To avoid frequent allocations, double their size when they have to grow (like Rust's Vec), and with reasonable minimum capacities.

Copy link
Member Author

overlookmotel commented Mar 19, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more


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.

@overlookmotel overlookmotel marked this pull request as ready for review March 19, 2026 00:16
@overlookmotel overlookmotel requested a review from camc314 as a code owner March 19, 2026 00:16
Copilot AI review requested due to automatic review settings March 19, 2026 00:16
@overlookmotel overlookmotel self-assigned this Mar 19, 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

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 Uint32Array backings.
  • 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.

@overlookmotel overlookmotel force-pushed the om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling branch 2 times, most recently from e20a6c3 to e08fd3f Compare March 19, 2026 00:24
@overlookmotel overlookmotel force-pushed the om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling branch from e08fd3f to 3ac4b1e Compare March 19, 2026 00:40
@overlookmotel overlookmotel force-pushed the om/03-18-perf_linter_plugins_share_empty_uint32array_across_multiple_places branch from 3b2206a to 6f6dda2 Compare March 19, 2026 00:40
@graphite-app graphite-app bot added the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
@overlookmotel overlookmotel removed the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026
@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Mar 20, 2026 — with Graphite App
Copy link
Member Author

overlookmotel commented Mar 20, 2026

Merge activity

  • Mar 20, 10:53 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 21, 12:20 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 21, 12:21 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Mar 21, 12:22 PM UTC: The merge label '0-merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.

@overlookmotel
Copy link
Member Author

Have folded this into other PRs now.

@overlookmotel overlookmotel deleted the om/03-18-perf_linter_plugins_grow_uint32array_s_by_doubling branch March 21, 2026 22:12
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

0-merge Merge with Graphite Merge Queue 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