Skip to content

perf(parser): eat whitespace after line break#2353

Merged
Boshen merged 4 commits intomainfrom
02-08-perf_parser_eat_whitespace_after_line_break
Feb 9, 2024
Merged

perf(parser): eat whitespace after line break#2353
Boshen merged 4 commits intomainfrom
02-08-perf_parser_eat_whitespace_after_line_break

Conversation

@overlookmotel
Copy link
Copy Markdown
Member

@overlookmotel overlookmotel commented Feb 8, 2024

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

@overlookmotel
Copy link
Copy Markdown
Member Author

overlookmotel commented Feb 8, 2024

@overlookmotel overlookmotel force-pushed the 02-08-perf_parser_eat_whitespace_after_line_break branch from eb7db91 to a3d4ea3 Compare February 8, 2024 22:18
@codspeed-hq
Copy link
Copy Markdown

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
Copy Markdown
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
@Boshen Boshen deleted the 02-08-perf_parser_eat_whitespace_after_line_break branch February 9, 2024 04:02
@overlookmotel
Copy link
Copy Markdown
Member 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
Copy Markdown
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
Copy Markdown
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
Copy Markdown
Member 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