Skip to content

perf(semantic): compute identifier hash incrementally during lexing#18454

Closed
Boshen wants to merge 1 commit into01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computationfrom
01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing
Closed

perf(semantic): compute identifier hash incrementally during lexing#18454
Boshen wants to merge 1 commit into01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computationfrom
01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Jan 23, 2026

Add incremental hashing to the lexer so identifier hashes are computed
while scanning bytes, avoiding a second pass over the data.

  • Add identifier_hasher field to Lexer and LexerCheckpoint
  • Add hash_identifier: true variant to byte_search! macro
  • Update identifier_name_handler to hash first byte and use hashing variant
  • Handle unicode/escape cold paths with appropriate hashing
  • Update get_ident() to use Ident::new_with_hash() with precomputed hash
  • Re-export IncrementalIdentHasher from oxc_span

Co-Authored-By: Claude Opus 4.5 [email protected]

Copy link
Member Author

Boshen commented Jan 23, 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 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 Jan 23, 2026

CodSpeed Performance Report

Merging this PR will degrade performance by 20.46%

Comparing 01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing (364ff6d) with 01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation (6d1cc47)

Summary

❌ 4 regressed benchmarks
✅ 38 untouched benchmarks
⏩ 3 skipped benchmarks1

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation lexer[binder.ts] 885.2 µs 1,113 µs -20.46%
Simulation lexer[cal.com.tsx] 5.5 ms 6.6 ms -17.62%
Simulation lexer[RadixUIAdoptionSection.jsx] 21.2 µs 23.3 µs -9.05%
Simulation lexer[react.development.js] 358.3 µs 430.9 µs -16.84%

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.

@Boshen Boshen force-pushed the 01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing branch from 86d7486 to dca2b3b Compare January 23, 2026 13:49
@Boshen Boshen force-pushed the 01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation branch from 1a13ac9 to a25cdb3 Compare January 23, 2026 13:49
@Boshen Boshen force-pushed the 01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing branch 3 times, most recently from 2abd0b1 to 364ff6d Compare January 24, 2026 03:12
@Boshen Boshen force-pushed the 01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation branch from 1c918ed to 6d1cc47 Compare January 24, 2026 03:12
@Boshen Boshen marked this pull request as ready for review January 24, 2026 03:13
@Boshen Boshen marked this pull request as draft January 24, 2026 05:26
@Boshen Boshen changed the title perf(lexer): compute identifier hash incrementally during lexing perf(semantic): compute identifier hash incrementally during lexing Jan 24, 2026
@github-actions github-actions bot added A-semantic Area - Semantic A-minifier Area - Minifier A-transformer Area - Transformer / Transpiler labels Jan 24, 2026
@Boshen Boshen force-pushed the 01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing branch from e4e672d to 364ff6d Compare January 24, 2026 07:20
@Boshen Boshen force-pushed the 01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation branch from 6d1cc47 to fc67309 Compare January 24, 2026 11:16
@Boshen Boshen force-pushed the 01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing branch from 364ff6d to db265d1 Compare January 24, 2026 11:16
@Boshen Boshen marked this pull request as ready for review January 24, 2026 11:16
Add incremental hashing to the lexer so identifier hashes are computed
while scanning bytes, avoiding a second pass over the data.

- Add `identifier_hasher` field to `Lexer` and `LexerCheckpoint`
- Add `hash_identifier: true` variant to `byte_search!` macro
- Update `identifier_name_handler` to hash first byte and use hashing variant
- Handle unicode/escape cold paths with appropriate hashing
- Update `get_ident()` to use `Ident::new_with_hash()` with precomputed hash
- Re-export `IncrementalIdentHasher` from `oxc_span`

Co-Authored-By: Claude Opus 4.5 <[email protected]>
@Boshen Boshen force-pushed the 01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation branch from fc67309 to ece98da Compare January 24, 2026 13:41
@Boshen Boshen force-pushed the 01-23-perf_lexer_compute_identifier_hash_incrementally_during_lexing branch from db265d1 to ee1560a Compare January 24, 2026 13:41
@Boshen Boshen closed this Feb 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-minifier Area - Minifier A-parser Area - Parser A-semantic Area - Semantic A-transformer Area - Transformer / Transpiler 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

Comments