Skip to content

perf(parser): faster parsing TemplateElements#10678

Merged
graphite-app[bot] merged 1 commit intomainfrom
04-28-perf_parser_faster_parsing_templateelement_s
Apr 28, 2025
Merged

perf(parser): faster parsing TemplateElements#10678
graphite-app[bot] merged 1 commit intomainfrom
04-28-perf_parser_faster_parsing_templateelement_s

Conversation

@overlookmotel
Copy link
Member

@overlookmotel overlookmotel commented Apr 28, 2025

Speed up parsing TemplateElement a little by:

  • Only slice source text once to get raw (rather than slicing a slice).
  • Fast path for when TemplateElement contains no escapes:
    • Don't slice source text again to get cooked - just copy the existing Atom for raw.
    • Don't search for \r in raw - it can't be there because otherwise escaped would be true.

This also allows removing some code repetition.

@github-actions github-actions bot added A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance labels Apr 28, 2025
@overlookmotel overlookmotel force-pushed the 04-28-perf_parser_faster_parsing_templateelement_s branch from 1a769a3 to 6213662 Compare April 28, 2025 16:05
Copy link
Member Author

overlookmotel commented Apr 28, 2025


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.

@overlookmotel overlookmotel force-pushed the 04-28-perf_parser_faster_parsing_templateelement_s branch from 6213662 to 4349224 Compare April 28, 2025 16:05
@codspeed-hq
Copy link

codspeed-hq bot commented Apr 28, 2025

CodSpeed Instrumentation Performance Report

Merging #10678 will not alter performance

Comparing 04-28-perf_parser_faster_parsing_templateelement_s (4861a62) with main (06fde2a)

Summary

✅ 36 untouched benchmarks

@overlookmotel overlookmotel marked this pull request as ready for review April 28, 2025 16:16
@overlookmotel overlookmotel requested a review from Boshen April 28, 2025 16:16
@Boshen Boshen added the 0-merge Merge with Graphite Merge Queue label Apr 28, 2025
Copy link
Member

Boshen commented Apr 28, 2025

Merge activity

Speed up parsing `TemplateElement` a little by:

* Only slice source text once to get `raw` (rather than slicing a slice).
* Fast path for when `TemplateElement` contains no escapes:
  * Don't slice source text again to get `cooked` - just copy the existing `Atom` for `raw`.
  * Don't search for `\r` in `raw` - it can't be there because otherwise `escaped` would be `true`.

This also allows removing some code repetition.
@graphite-app graphite-app bot force-pushed the 04-28-perf_parser_faster_parsing_templateelement_s branch from 4349224 to 4861a62 Compare April 28, 2025 16:44
@graphite-app graphite-app bot merged commit 4861a62 into main Apr 28, 2025
26 checks passed
@graphite-app graphite-app bot deleted the 04-28-perf_parser_faster_parsing_templateelement_s branch April 28, 2025 16:51
@graphite-app graphite-app bot removed the 0-merge Merge with Graphite Merge Queue label Apr 28, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-parser Area - Parser C-performance Category - Solution not expected to change functional behavior, only performance

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants