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): eat whitespace after line break #2353

Merged
merged 4 commits into from
Feb 9, 2024

Conversation

overlookmotel
Copy link
Collaborator

@overlookmotel overlookmotel commented Feb 8, 2024

Uses the byte_search! macro introduced in #2352 to consume whitespace after a line break.

Copy link

codspeed-hq bot commented Feb 8, 2024

CodSpeed Performance Report

Merging #2353 will improve performances by 27.35%

Comparing 02-08-perf_parser_eat_whitespace_after_line_break (d89b376) with 02-08-perf_parser_lex_identifiers_as_bytes_not_chars (070d3c4)

Summary

⚡ 7 improvements
✅ 20 untouched benchmarks

Benchmarks breakdown

Benchmark 02-08-perf_parser_lex_identifiers_as_bytes_not_chars 02-08-perf_parser_eat_whitespace_after_line_break Change
parser[checker.ts] 369.2 ms 349.7 ms +5.56%
lexer[RadixUIAdoptionSection.jsx] 148.7 µs 129.9 µs +14.48%
minifier[typescript.js] 1.6 s 1.6 s +4.08%
lexer[checker.ts] 95.6 ms 75.1 ms +27.35%
lexer[cal.com.tsx] 43 ms 36.9 ms +16.58%
lexer[pdf.mjs] 22.5 ms 20.3 ms +10.92%
lexer[antd.js] 157.7 ms 146.1 ms +7.94%

@overlookmotel overlookmotel force-pushed the 02-08-perf_parser_lex_identifiers_as_bytes_not_chars branch from 5b9f1a7 to 070d3c4 Compare February 9, 2024 02:13
@overlookmotel overlookmotel force-pushed the 02-08-perf_parser_eat_whitespace_after_line_break branch from a3d4ea3 to d89b376 Compare February 9, 2024 02:18
@Boshen Boshen force-pushed the 02-08-perf_parser_lex_identifiers_as_bytes_not_chars branch from 070d3c4 to 9a8d7b7 Compare February 9, 2024 03:55
Base automatically changed from 02-08-perf_parser_lex_identifiers_as_bytes_not_chars to main February 9, 2024 04:01
@Boshen
Copy link
Member

Boshen commented Feb 9, 2024

I LOVE all the performance improvements.

One nitpick is the amount of macros we are introducing, it may impact compilation speed and hinder other contributors to navigate the code.

It's troublesome but I think we can expand all the code once we are done ... just like how I did it with the visitors https://github.com/oxc-project/oxc/blob/main/crates/oxc_ast/src/visit.rs ... I wrote it manually 😅

@Boshen Boshen merged commit 8376f15 into main Feb 9, 2024
23 of 41 checks passed
@Boshen Boshen deleted the 02-08-perf_parser_eat_whitespace_after_line_break branch February 9, 2024 04:02
@overlookmotel
Copy link
Collaborator Author

It's been fun! By our joint efforts, over the past month the checker.ts parser benchmark has gone from 533ms to 350ms.

Maybe you can update the website where it says "2x faster than SWC" to "3x faster"!

It's funny, originally I had it all written out by hand, but it was so repetitive I found it hard to follow, so that's why I brought in the macro.

Have you noticed a difference in compilation times? I haven't noticed one, but OXC compilation falls into the "fast enough" category for me, especially after working on SWC which was so hideously slow in that department.

@Boshen
Copy link
Member

Boshen commented Feb 9, 2024

Maybe you can update the website where it says "2x faster than SWC" to "3x faster"!

https://github.com/oxc-project/bench-javascript-parser-written-in-rust will automatically pick up the latest release via renovate bot, and I'll update the numbers from that benchmark.

@Boshen
Copy link
Member

Boshen commented Feb 9, 2024

Have you noticed a difference in compilation times?

We'll need to look at cargo build --timings

@overlookmotel
Copy link
Collaborator Author

Would you be willing to cut a release at this point? I think the speed boost in parser justifies it, and I'm dying to see the updated comparison to SWC.

IWANABETHATGUY pushed a commit to IWANABETHATGUY/oxc that referenced this pull request May 29, 2024
Uses the `byte_search!` macro introduced in oxc-project#2352 to consume whitespace after a line break.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-parser Area - Parser
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants