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

Reduced regular expression processing in the form of processing white space first #237

Merged
merged 1 commit into from
Jan 26, 2025

Conversation

naitoh
Copy link
Contributor

@naitoh naitoh commented Jan 26, 2025

Benchmark

RUBYLIB= BUNDLER_ORIG_RUBYLIB= /Users/naitoh/.rbenv/versions/3.4.1/bin/ruby -v -S benchmark-driver /Users/naitoh/ghq/github.com/naitoh/rexml/benchmark/parse.yaml
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]
Calculating -------------------------------------
                         before       after  before(YJIT)  after(YJIT)
                 dom     19.849      20.109        36.064       38.655 i/s -     100.000 times in 5.038102s 4.972864s 2.772838s 2.586981s
                 sax     30.339      30.449        52.946       54.873 i/s -     100.000 times in 3.296102s 3.284176s 1.888722s 1.822391s
                pull     34.785      34.916        65.808       65.219 i/s -     100.000 times in 2.874810s 2.863976s 1.519581s 1.533305s
              stream     34.766      34.921        61.920       63.277 i/s -     100.000 times in 2.876359s 2.863571s 1.615000s 1.580354s

Comparison:
                              dom
         after(YJIT):        38.7 i/s
        before(YJIT):        36.1 i/s - 1.07x  slower
               after:        20.1 i/s - 1.92x  slower
              before:        19.8 i/s - 1.95x  slower

                              sax
         after(YJIT):        54.9 i/s
        before(YJIT):        52.9 i/s - 1.04x  slower
               after:        30.4 i/s - 1.80x  slower
              before:        30.3 i/s - 1.81x  slower

                             pull
        before(YJIT):        65.8 i/s
         after(YJIT):        65.2 i/s - 1.01x  slower
               after:        34.9 i/s - 1.88x  slower
              before:        34.8 i/s - 1.89x  slower

                           stream
         after(YJIT):        63.3 i/s
        before(YJIT):        61.9 i/s - 1.02x  slower
               after:        34.9 i/s - 1.81x  slower
              before:        34.8 i/s - 1.82x  slower
  • YJIT=ON : 0.99x - 1.07x faster
  • YJIT=OFF : 1.00x - 1.01x faster

…space first

## Benchmark
```
RUBYLIB= BUNDLER_ORIG_RUBYLIB= /Users/naitoh/.rbenv/versions/3.4.1/bin/ruby -v -S benchmark-driver /Users/naitoh/ghq/github.com/naitoh/rexml/benchmark/parse.yaml
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +PRISM [arm64-darwin24]
Calculating -------------------------------------
                         before       after  before(YJIT)  after(YJIT)
                 dom     19.849      20.109        36.064       38.655 i/s -     100.000 times in 5.038102s 4.972864s 2.772838s 2.586981s
                 sax     30.339      30.449        52.946       54.873 i/s -     100.000 times in 3.296102s 3.284176s 1.888722s 1.822391s
                pull     34.785      34.916        65.808       65.219 i/s -     100.000 times in 2.874810s 2.863976s 1.519581s 1.533305s
              stream     34.766      34.921        61.920       63.277 i/s -     100.000 times in 2.876359s 2.863571s 1.615000s 1.580354s

Comparison:
                              dom
         after(YJIT):        38.7 i/s
        before(YJIT):        36.1 i/s - 1.07x  slower
               after:        20.1 i/s - 1.92x  slower
              before:        19.8 i/s - 1.95x  slower

                              sax
         after(YJIT):        54.9 i/s
        before(YJIT):        52.9 i/s - 1.04x  slower
               after:        30.4 i/s - 1.80x  slower
              before:        30.3 i/s - 1.81x  slower

                             pull
        before(YJIT):        65.8 i/s
         after(YJIT):        65.2 i/s - 1.01x  slower
               after:        34.9 i/s - 1.88x  slower
              before:        34.8 i/s - 1.89x  slower

                           stream
         after(YJIT):        63.3 i/s
        before(YJIT):        61.9 i/s - 1.02x  slower
               after:        34.9 i/s - 1.81x  slower
              before:        34.8 i/s - 1.82x  slower
```
- YJIT=ON : 0.99x - 1.07x faster
- YJIT=OFF : 1.00x - 1.01x faster
@naitoh naitoh marked this pull request as ready for review January 26, 2025 10:44
@naitoh naitoh requested a review from kou January 26, 2025 10:45
@kou kou merged commit 67d21be into ruby:master Jan 26, 2025
64 of 67 checks passed
@kou
Copy link
Member

kou commented Jan 26, 2025

Thanks.

@naitoh naitoh deleted the reduced_regular_expression_pull_event branch January 26, 2025 12:01
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants