Skip to content

perf(linter/plugins): collect tokens even when not needed#19970

Closed
overlookmotel wants to merge 1 commit intographite-base/19970from
om/03-03-perf_linter_plugins_collect_tokens_even_when_not_needed
Closed

perf(linter/plugins): collect tokens even when not needed#19970
overlookmotel wants to merge 1 commit intographite-base/19970from
om/03-03-perf_linter_plugins_collect_tokens_even_when_not_needed

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Mar 3, 2026

Unconditionally collect tokens in linter, even if they're not needed (files which are not linted with JS plugins).

This is wasteful in terms of memory, but according to CodSpeed is slightly faster (+0.5%) because it removes the if self.config.tokens() branch from Lexer::finish_next_inner (self.config.tokens() is const-folded to true). The branch costs more than pushing the Token to the Vec<Token>!

But this needs measuring in real world to see what actual perf impact is, so can judge the memory/perf trade-off accurately.

Copy link
Member Author

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 hot fixes, skip the queue and merge this PR next

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 C-performance Category - Solution not expected to change functional behavior, only performance labels Mar 3, 2026
@overlookmotel overlookmotel self-assigned this Mar 3, 2026
@overlookmotel overlookmotel added the A-linter-plugins Area - Linter JS plugins label Mar 3, 2026
@codspeed-hq
Copy link

codspeed-hq bot commented Mar 3, 2026

Merging this PR will not alter performance

✅ 53 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing om/03-03-perf_linter_plugins_collect_tokens_even_when_not_needed (ffead33) with om/03-03-perf_linter_plugins_store_tokens_as_a_box_token_ (c13b437)

Open in CodSpeed

Footnotes

  1. 3 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

@overlookmotel overlookmotel force-pushed the om/03-03-perf_linter_plugins_collect_tokens_even_when_not_needed branch from da82af3 to ffead33 Compare March 3, 2026 15:19
@overlookmotel overlookmotel force-pushed the om/03-03-perf_linter_plugins_store_tokens_as_a_box_token_ branch from 6284f43 to c13b437 Compare March 3, 2026 15:19
@graphite-app graphite-app bot changed the base branch from om/03-03-perf_linter_plugins_store_tokens_as_a_box_token_ to graphite-base/19970 March 3, 2026 16:24
@overlookmotel
Copy link
Member Author

I don't think this is worthwhile.

@overlookmotel overlookmotel deleted the om/03-03-perf_linter_plugins_collect_tokens_even_when_not_needed branch March 8, 2026 13:13
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.

1 participant