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): faster lexing template strings #2541

Merged
merged 1 commit into from
Feb 29, 2024

Conversation

overlookmotel
Copy link
Collaborator

@overlookmotel overlookmotel commented Feb 28, 2024

Speed up lexing template strings.

This was the last use of AutoCow remaining in the lexer, and it's now removed.

Implementation is quite complex, to avoid repeatedly branching on whether an unescaped string is required or not (the way AutoCow did). I tried to simplify it down to a single function, but this hurt performance significantly.

Benchmarks do not show much movement, but I believe that's because there aren't many template strings in the benchmarks. Where there are template strings, I believe this speeds up lexing them significantly.

Copy link
Collaborator Author

overlookmotel commented Feb 28, 2024

Copy link

codspeed-hq bot commented Feb 29, 2024

CodSpeed Performance Report

Merging #2541 will not alter performance

Comparing 02-28-perf_parser_faster_lexing_template_strings-v2 (286a4a9) with main (9d7ea6b)

Summary

✅ 27 untouched benchmarks

@overlookmotel overlookmotel force-pushed the 02-28-perf_parser_faster_lexing_template_strings-v2 branch from a0c2576 to 8d9cd94 Compare February 29, 2024 03:05
@overlookmotel overlookmotel marked this pull request as ready for review February 29, 2024 03:05
Copy link
Member

Boshen commented Feb 29, 2024

Merge activity

  • Feb 29, 12:22 AM EST: @Boshen started a stack merge that includes this pull request via Graphite.
  • Feb 29, 12:23 AM EST: Graphite rebased this pull request as part of a merge.
  • Feb 29, 12:28 AM EST: @Boshen merged this pull request with Graphite.

Base automatically changed from 02-28-refactor_parser_single_function_for_all_string_slicing to main February 29, 2024 05:22
@Boshen Boshen force-pushed the 02-28-perf_parser_faster_lexing_template_strings-v2 branch from 8d9cd94 to 286a4a9 Compare February 29, 2024 05:23
@Boshen Boshen merged commit 5a13714 into main Feb 29, 2024
23 checks passed
@Boshen Boshen deleted the 02-28-perf_parser_faster_lexing_template_strings-v2 branch February 29, 2024 05:28
IWANABETHATGUY pushed a commit to IWANABETHATGUY/oxc that referenced this pull request May 29, 2024
Speed up lexing template strings.

This was the last use of `AutoCow` remaining in the lexer, and it's now removed.

Implementation is quite complex, to avoid repeatedly branching on whether an unescaped string is required or not (the way `AutoCow` did). I tried to simplify it down to a single function, but this hurt performance significantly.

Benchmarks do not show much movement, but I believe that's because there aren't many template strings in the benchmarks. Where there are template strings, I believe this speeds up lexing them significantly.
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