Skip to content

refactor(oxc_str): add IncrementalIdentHasher for byte-by-byte hash computation#18451

Closed
Boshen wants to merge 2 commits into01-23-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hashfrom
01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation
Closed

refactor(oxc_str): add IncrementalIdentHasher for byte-by-byte hash computation#18451
Boshen wants to merge 2 commits into01-23-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hashfrom
01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation

Conversation

@Boshen
Copy link
Member

@Boshen Boshen commented Jan 23, 2026

Replace the complex const FxHash implementation with a simpler incremental
hasher that can compute hashes byte-by-byte during lexing.

  • Add IncrementalIdentHasher struct with write_byte(), write_bytes(), and finish() methods
  • Add Ident::new_with_hash() for creating Idents with precomputed hash
  • Simplify compute_hash() const function to use the same incremental algorithm
  • Update Ident::new() to use the incremental hasher

Co-Authored-By: Claude Opus 4.5 noreply@anthropic.com

@github-actions github-actions bot added the C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior label Jan 23, 2026
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

Merging this PR will not alter performance

✅ 42 untouched benchmarks
⏩ 3 skipped benchmarks1


Comparing 01-23-refactor_oxc_str_add_incrementalidenthasher_for_byte-by-byte_hash_computation (6d1cc47) with 01-23-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hash (046b4e6)2

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.

  2. No successful run was found on 01-23-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hash (cceaf1e) during the generation of this report, so 9a7c202 was used instead as the comparison base. There might be some changes unrelated to this pull request in this report.

@Boshen Boshen force-pushed the 01-23-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hash branch from d4ca5d4 to 046b4e6 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-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hash branch from 046b4e6 to cceaf1e 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 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-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hash branch from cceaf1e to f04def0 Compare January 24, 2026 11:16
Boshen and others added 2 commits January 24, 2026 21:26
…omputation

Replace the complex const FxHash implementation with a simpler incremental
hasher that can compute hashes byte-by-byte during lexing.

- Add `IncrementalIdentHasher` struct with `write_byte()`, `write_bytes()`, and `finish()` methods
- Add `Ident::new_with_hash()` for creating Idents with precomputed hash
- Simplify `compute_hash()` const function to use the same incremental algorithm
- Update `Ident::new()` to use the incremental hasher

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
The IncrementalIdentHasher was using `usize` which is 32-bit on wasm32,
causing overflow errors:
- The constant K doesn't fit in 32 bits
- The `>> 32` shift would overflow on 32-bit

Changed to use explicit `u64` for consistent behavior across platforms.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
@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 requested a review from camc314 as a code owner January 24, 2026 13:41
@Boshen Boshen force-pushed the 01-23-refactor_parser_add_cur_ident_for_identifiers_with_precomputed_hash branch from f04def0 to 26aca72 Compare January 24, 2026 13:41
@github-actions github-actions bot added the A-linter Area - Linter label Jan 24, 2026
@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-linter Area - Linter C-cleanup Category - technical debt or refactoring. Solution not expected to change behavior

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant