8000 Improve `Text.check` performance by naitoh · Pull Request #256 · ruby/rexml · GitHub
[go: up one dir, main page]
More Web Proxy on the site http://driver.im/
Skip to content

Improve Text.check performance #256

8000 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

Merged
merged 1 commit into from
May 29, 2025

Conversation

naitoh
Copy link
Contributor
@naitoh naitoh commented May 28, 2025

The doctype parameter of Text.check is not being used.
Changing the doctype parameter to an optional parameter improves the parsing speed of the DOM.

Benchmark

                         before       after  before(YJIT)  after(YJIT)
                 dom     19.854      23.805        33.969       37.712 i/s -     100.000 times in 5.036779s 4.200839s 2.943877s 2.651709s
                 sax     29.436      30.494        54.070       55.089 i/s -     100.000 times in 3.397155s 3.279348s 1.849463s 1.815255s
                pull     34.908      34.857        62.969       64.895 i/s -     100.000 times in 2.864651s 2.868842s 1.588082s 1.540939s
              stream     34.570      34.281        60.616       60.355 i/s -     100.000 times in 2.892656s 2.917080s 1.649737s 1.656866s

Comparison:
                              dom
         after(YJIT):        37.7 i/s
        before(YJIT):        34.0 i/s - 1.11x  slower
               after:        23.8 i/s - 1.58x  slower
              before:        19.9 i/s - 1.90x  slower

                              sax
         after(YJIT):        55.1 i/s
        before(YJIT):        54.1 i/s - 1.02x  slower
               after:        30.5 i/s - 1.81x  slower
              before:        29.4 i/s - 1.87x  slower

                             pull
         after(YJIT):        64.9 i/s
        before(YJIT):        63.0 i/s - 1.03x  slower
              before:        34.9 i/s - 1.86x  slower
               after:        34.9 i/s - 1.86x  slower

                           stream
        before(YJIT):        60.6 i/s
         after(YJIT):        60.4 i/s - 1.00x  slower
              before:        34.6 i/s - 1.75x  slower
               after:        34.3 i/s - 1.77x  slower
  • YJIT=ON : 1.00x - 1.11x faster (dom: 1.11x faster)
  • YJIT=OFF : 1.00x - 1.20x faster (dom: 1.20x faster)

## Benchmark

```
                         before       after  before(YJIT)  after(YJIT)
                 dom     19.854      23.805        33.969       37.712 i/s -     100.000 times in 5.036779s 4.200839s 2.943877s 2.651709s
                 sax     29.436      30.494        54.070       55.089 i/s -     100.000 times in 3.397155s 3.279348s 1.849463s 1.815255s
                pull     34.908      34.857        62.969       64.895 i/s -     100.000 times in 2.864651s 2.868842s 1.588082s 1.540939s
              stream     34.570      34.281        60.616       60.355 i/s -     100.000 times in 2.892656s 2.917080s 1.649737s 1.656866s

Comparison:
                              dom
         after(YJIT):        37.7 i/s
        before(YJIT):        34.0 i/s - 1.11x  slower
               after:        23.8 i/s - 1.58x  slower
              before:        19.9 i/s - 1.90x  slower

                              sax
         after(YJIT):        55.1 i/s
        before(YJIT):        54.1 i/s - 1.02x  slower
               after:        30.5 i/s - 1.81x  slower
              before:        29.4 i/s - 1.87x  slower

                             pull
         after(YJIT):        64.9 i/s
        before(YJIT):        63.0 i/s - 1.03x  slower
              before:        34.9 i/s - 1.86x  slower
               after:        34.9 i/s - 1.86x  slower

                           stream
        before(YJIT):        60.6 i/s
         after(YJIT):        60.4 i/s - 1.00x  slower
              before:        34.6 i/s - 1.75x  slower
               after:        34.3 i/s - 1.77x  slower
```

- YJIT=ON : 1.00x - 1.11x faster
- YJIT=OFF : 1.00x - 1.20x faster
@naitoh naitoh marked this pull request as ready for review May 28, 2025 22:29
@naitoh naitoh requested a review from kou May 28, 2025 22:30
@kou kou merged commit 3dc9eca into ruby:master May 29, 2025
67 checks passed
@kou
Copy link
Member
kou commented May 29, 2025

Thanks.

@naitoh naitoh deleted the remove_doctype_from_Text_check_param branch May 29, 2025 11:36
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
0