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

Faster Variable BlockBody Matching #1833

Merged
merged 2 commits into from
Oct 28, 2024
Merged

Faster Variable BlockBody Matching #1833

merged 2 commits into from
Oct 28, 2024

Conversation

ggmichaelgo
Copy link
Contributor

@ggmichaelgo ggmichaelgo commented Oct 23, 2024

Benchmark testing result:

bundle exec rake benchmark:run 

Before:

ruby 3.4.0dev (2024-04-23T16:59:11Z v3.4.0-pshopify-pr.. 70b931820e) +YJIT [arm64-darwin23]
Warming up --------------------------------------
              parse:    10.000 i/100ms
             render:    72.000 i/100ms
     parse & render:     8.000 i/100ms
Calculating -------------------------------------
              parse:     97.222 (± 1.0%) i/s   (10.29 ms/i) -    980.000 in  10.081357s
             render:    695.303 (± 2.7%) i/s    (1.44 ms/i) -      6.984k in  10.053073s
     parse & render:     81.088 (± 2.5%) i/s   (12.33 ms/i) -    816.000 in  10.069440s

After:

ruby 3.4.0dev (2024-04-23T16:59:11Z v3.4.0-pshopify-pr.. 70b931820e) +YJIT [arm64-darwin23]
Warming up --------------------------------------
              parse:    10.000 i/100ms
             render:    70.000 i/100ms
     parse & render:     8.000 i/100ms
Calculating -------------------------------------
              parse:    101.534 (± 0.0%) i/s    (9.85 ms/i) -      1.020k in  10.046007s
             render:    687.268 (± 1.3%) i/s    (1.46 ms/i) -      6.930k in  10.084962s
     parse & render:     84.576 (± 2.4%) i/s   (11.82 ms/i) -    848.000 in  10.033386s

This PR improves the parsing speed by ~4%

@ggmichaelgo ggmichaelgo changed the title faster-variable-parse Faster Variable BlockBody Matching Oct 23, 2024
@ggmichaelgo ggmichaelgo marked this pull request as ready for review October 23, 2024 14:18
@ggmichaelgo ggmichaelgo requested review from ianks, a team and Youssef-Mak October 23, 2024 14:18
parse_end = token.length - 3
parse_end -= 1 if token[parse_end] == "-"

markup = token[i..parse_end]
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I should use byteslice here instead of creating a range

@ggmichaelgo ggmichaelgo force-pushed the fast-variable-parse branch 4 times, most recently from 5245128 to d1c309f Compare October 25, 2024 18:39
@ggmichaelgo ggmichaelgo merged commit b419648 into main Oct 28, 2024
11 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants