Skip to content

Conversation

@camchenry
Copy link
Member

@camchenry camchenry commented Oct 19, 2025

Profiling shows that segmenting into graphemes is much slower than just looking at the number of bytes. A simple check on is_ascii allows us to avoid splitting into graphemes and use the identifier length instead, which is much faster. We could optimize this further in the future by doing some faster ASCII check, but this is a good start.

@github-actions github-actions bot added A-linter Area - Linter C-performance Category - Solution not expected to change functional behavior, only performance labels Oct 19, 2025
Copy link
Member Author

camchenry commented Oct 19, 2025


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.

@codspeed-hq
Copy link

codspeed-hq bot commented Oct 19, 2025

CodSpeed Performance Report

Merging #14767 will not alter performance

Comparing 10-18-perf_linter_id-length_check_if_ident_is_ascii_before_segmenting (60a9f3d) with main (86ecae1)

Summary

✅ 4 untouched
⏩ 33 skipped1

Footnotes

  1. 33 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.

@camchenry camchenry marked this pull request as ready for review October 19, 2025 04:07
@camchenry camchenry requested a review from camc314 as a code owner October 19, 2025 04:07
@graphite-app graphite-app bot changed the base branch from 10-16-perf_linter_remove_simple_phf_map_calls to graphite-base/14767 October 19, 2025 07:46
@graphite-app graphite-app bot force-pushed the 10-18-perf_linter_id-length_check_if_ident_is_ascii_before_segmenting branch from 1e5e67e to 949a636 Compare October 19, 2025 07:51
@graphite-app graphite-app bot force-pushed the graphite-base/14767 branch from b42a79f to 86ecae1 Compare October 19, 2025 07:51
@graphite-app graphite-app bot changed the base branch from graphite-base/14767 to main October 19, 2025 07:51
@graphite-app graphite-app bot force-pushed the 10-18-perf_linter_id-length_check_if_ident_is_ascii_before_segmenting branch from 949a636 to 60a9f3d Compare October 19, 2025 07:51
@camc314 camc314 added the 0-merge Merge with Graphite Merge Queue label Oct 20, 2025
Copy link
Contributor

camc314 commented Oct 20, 2025

Merge activity

…14767)

Profiling shows that segmenting into graphemes is much slower than just looking at the number of bytes. A simple check on `is_ascii` allows us to avoid splitting into graphemes and use the identifier length instead, which is much faster. We could optimize this further in the future by doing some faster ASCII check, but this is a good start.
Copilot AI review requested due to automatic review settings October 20, 2025 08:22
@graphite-app graphite-app bot force-pushed the 10-18-perf_linter_id-length_check_if_ident_is_ascii_before_segmenting branch from 60a9f3d to 92b4302 Compare October 20, 2025 08:22
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.

Copilot encountered an error and was unable to review this pull request. You can try again by re-requesting a review.

@graphite-app graphite-app bot merged commit 92b4302 into main Oct 20, 2025
20 checks passed
@graphite-app graphite-app bot deleted the 10-18-perf_linter_id-length_check_if_ident_is_ascii_before_segmenting branch October 20, 2025 08:26
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Oct 20, 2025
@camc314 camc314 self-assigned this Oct 20, 2025
graphite-app bot pushed a commit that referenced this pull request Oct 20, 2025
…ks (#14821)

Previous PR (#14767) implemented an initial ASCII check, but I forgot to add it to the other identifier checks as well. This now adds the fast path ASCII check to all of the branches for this rule.

In addition, we no longer need to call `.to_string()` to allocate for each identifier, we can simply do the exceptions check with `&str`.

This should greatly benefit large files which have lots of identifiers, but this will pretty much universally improve perf on every file since this rule runs on every identifier and almost every JS file has identifiers.

<img width="714" height="535" alt="image" src="https://github.com/user-attachments/assets/f67a43e8-0e91-4f6d-805b-a031f9881c74" />
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-linter Area - Linter 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.

3 participants