Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

perf(parser): support peeking over bytes #4304

Merged
merged 1 commit into from
Jul 30, 2024
Merged

Conversation

lucab
Copy link
Collaborator

@lucab lucab commented Jul 16, 2024

Closes #3291

@github-actions github-actions bot added the A-parser Area - Parser label Jul 16, 2024
Copy link
Collaborator Author

lucab commented Jul 16, 2024

This stack of pull requests is managed by Graphite. Learn more about stacking.

Join @lucab and the rest of your teammates on Graphite Graphite

Copy link

graphite-app bot commented Jul 16, 2024

Your org has enabled the Graphite merge queue for merging into main

Add the label “merge” to the PR and Graphite will automatically add it to the merge queue when it’s ready to merge. Or use the label “hotfix” to add to the merge queue as a hot fix.

You must have a Graphite account and log in to Graphite in order to use the merge queue. Sign up using this link.

Copy link

codspeed-hq bot commented Jul 16, 2024

CodSpeed Performance Report

Merging #4304 will not alter performance

Comparing ups/lexer-peek-bytes (c9c38a1) with main (732f4e2)

Summary

✅ 32 untouched benchmarks

@lucab lucab marked this pull request as ready for review July 16, 2024 16:11
@lucab lucab force-pushed the ups/parser-advance-ascii-eq branch from 529dde4 to 6a15bca Compare July 17, 2024 07:50
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Jul 27, 2024
Copy link

graphite-app bot commented Jul 27, 2024

Merge activity

  • Jul 26, 9:17 PM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 26, 9:17 PM EDT: Boshen added this pull request to the Graphite merge queue.
  • Jul 26, 9:21 PM EDT: The Graphite merge queue couldn't merge this PR because it had conflicts with the trunk branch.
  • Jul 30, 1:52 PM EDT: The merge label 'merge' was detected. This PR will be added to the Graphite merge queue once it meets the requirements.
  • Jul 30, 1:52 PM EDT: overlookmotel added this pull request to the Graphite merge queue.
  • Jul 30, 1:56 PM EDT: overlookmotel merged this pull request with the Graphite merge queue.

@Boshen Boshen force-pushed the ups/parser-advance-ascii-eq branch from 81d54e0 to 868fc87 Compare July 27, 2024 01:17
@Boshen Boshen changed the base branch from ups/parser-advance-ascii-eq to main July 27, 2024 01:20
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Jul 27, 2024
@lucab
Copy link
Collaborator Author

lucab commented Jul 29, 2024

Rebased to main, but this one too did not bring performance improvements.

crates/oxc_parser/src/lexer/source.rs Outdated Show resolved Hide resolved
crates/oxc_parser/src/lexer/jsx.rs Outdated Show resolved Hide resolved
crates/oxc_parser/src/lexer/numeric.rs Outdated Show resolved Hide resolved
crates/oxc_parser/src/lexer/numeric.rs Outdated Show resolved Hide resolved
crates/oxc_parser/src/lexer/regex.rs Outdated Show resolved Hide resolved
@overlookmotel
Copy link
Collaborator

@lucab There is a little bit of positive movement on benchmarks, but again it's disappointing that it's not more.

I'm sorry I feel like I've "lead you up the garden path" and wasted your time. I really expected these 2 changes to be proper rocket fuel, and I'm sorry it's not turned out that way after all your work.

There's one of my suggested changes which does need to be made as I think it's a bug at present. The rest are along the lines of "well if we're going to do this, let's go all the way" - feel free to ignore those ones if you feel you've already put as much work into this as you want to.

@lucab
Copy link
Collaborator Author

lucab commented Jul 29, 2024

@overlookmotel I'm sad the two PRs did not improve performance as expected, but I enjoyed walking the code and the cleanup is still worthy. I'll try to finish the missing pieces this week and ping you back for a review when ready.

@Boshen Boshen marked this pull request as draft July 30, 2024 10:47
@github-actions github-actions bot added the A-ast Area - AST label Jul 30, 2024
@lucab lucab marked this pull request as ready for review July 30, 2024 15:08
@lucab lucab requested a review from overlookmotel July 30, 2024 15:08
@lucab
Copy link
Collaborator Author

lucab commented Jul 30, 2024

Updated!

@overlookmotel overlookmotel added the 0-merge Merge with Graphite Merge Queue label Jul 30, 2024
@overlookmotel
Copy link
Collaborator

Thank you @lucab!

@graphite-app graphite-app bot merged commit c9c38a1 into main Jul 30, 2024
23 checks passed
@graphite-app graphite-app bot deleted the ups/lexer-peek-bytes branch July 30, 2024 17:56
Boshen pushed a commit that referenced this pull request Jul 31, 2024
Follow-on after #4304. Avoid using `saturating_sub` when plain `-` will do. `-` is cheaper - it's a single assembly instruction, whereas `saturating_sub` is usually 3 instructions.

https://godbolt.org/z/fo8Tcx6bK
@oxc-bot oxc-bot mentioned this pull request Aug 1, 2024
Boshen added a commit that referenced this pull request Aug 1, 2024
## [0.23.0] - 2024-08-01

- 27fd062 sourcemap: [**BREAKING**] Avoid passing `Result`s (#4541)
(overlookmotel)

### Features

- a558492 codegen: Implement `BinaryExpressionVisitor` (#4548) (Boshen)
- 7446e98 codegen: Align more esbuild implementations (#4510) (Boshen)
- 35654e6 codegen: Align operator precedence with esbuild (#4509)
(Boshen)
- b952942 linter: Add eslint/no-unused-vars (⭐ attempt 3.2) (#4445)
(DonIsaac)
- 85e8418 linter: Add react/jsx-curly-brace-presence (#3949) (Don Isaac)
- cf1854b semantic: Remove `ReferenceFlags::Value` from non-type-only
exports that referenced type binding (#4511) (Dunqing)

### Bug Fixes

- b58ed80 codegen: Enable more test cases (#4585) (Boshen)
- 6a94e3f codegen: Fixes for esbuild test cases (#4503) (Boshen)
- d5c4b19 parser: Fix enum member parsing (#4543) (DonIsaac)

### Performance

- 4c6d19d allocator: Use capacity hint (#4584) (Luca Bruno)
- 7585e16 linter: Remove allocations for string comparisons (#4570)
(DonIsaac)
- 55a8763 parser: Faster decoding unicode escapes in identifiers (#4579)
(overlookmotel)
- ae1d38f parser: Fast path for ASCII when checking char after numeric
literal (#4577) (overlookmotel)
- 56ae615 parser: Make not at EOF the hot path in `Source` methods
(#4576) (overlookmotel)
- 25679e6 parser: Optimize `Lexer::hex_digit` (#4572) (overlookmotel)
- bb33bcc parser: Speed up lexing non-decimal numbers (#4571)
(overlookmotel)
- ab8509e parser: Use `-` not `saturating_sub` (#4561) (overlookmotel)
- c9c38a1 parser: Support peeking over bytes (#4304) (lucab)
- 0870ee1 parser: Get and check lookahead token (#4534) (lucab)
- d00014e sourcemap: Elide bounds checks in VLQ encoding (#4583)
(overlookmotel)
- 1fd9dd0 sourcemap: Use simd to escape JSON string (#4487)
(Brooooooklyn)

### Documentation

- 0914e47 ast: Add doc comments to literal nodes (#4551) (DonIsaac)
- c6a11be ast: Auto-generate doc comments for AstBuilder methods (#4471)
(DonIsaac)

### Refactor

- e68ed62 parser: Convert lexer byte handler for `|` to a single match
(#4575) (overlookmotel)
- bba824b parser: Convert `Lexer::read_minus` to a single match (#4574)
(overlookmotel)
- ef5418a parser: Convert `Lexer::read_left_angle` to a single match
(#4573) (overlookmotel)
- 9e5be78 parser: Add `Lexer::consume_2_chars` (#4569) (overlookmotel)
- 649913e parser: Extract `u8` not `&u8` when iterating over bytes
(#4568) (overlookmotel)
- 59f00c0 parser: Rename function (#4566) (overlookmotel)
- 8e3e910 parser: Rename vars (#4565) (overlookmotel)
- 0c0601f parser: Rename function (#4564) (overlookmotel)
- 0acc4a7 parser: Fetch 2 bytes in `?` byte handler (#4563)
(overlookmotel)
- 565eccf parser: Shorten lexer code (#4562) (overlookmotel)
- 148bdb5 parser: Adjust function inlining (#4530) (overlookmotel)
- 16c7b98 semantic: Move CatchClause scope binding logic to
visit_block_statement (#4505) (Dunqing)
- d6974d4 semantic: `AstNodeParentIter` fetch nodes lazily (#4533)
(overlookmotel)
- d914b14 semantic: Reusing the same reference (#4529) (Dunqing)
- 7b5e1f5 semantic: Use `is_empty()` instead of `len() == 0` (#4532)
(overlookmotel)
- 9db4259 semantic: Inline trivial methods (#4531) (overlookmotel)
- 7c42ffc sourcemap: Align Base64 chars lookup table to cache line
(#4535) (overlookmotel)
- 96602bf transformer/typescript: Determine whether to remove
`ExportSpeicifer` by `ReferenceFlags` (#4513) (Dunqing)
- e6a8af6 traverse: Speed up tests (#4538) (overlookmotel)

Co-authored-by: Boshen <1430279+Boshen@users.noreply.github.com>
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-ast Area - AST A-parser Area - Parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Convert lexer to iterate over bytes instead of chars
3 participants