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

⚡ Simplify and speed up thread-data response parsing #234

Merged
merged 1 commit into from
Nov 21, 2023

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Nov 21, 2023

One of the examples was incorrectly copied from RFC5256, and a missing SP was added. Note that this PR also makes the parser slightly more strict. We can add workarounds back in, if specific servers send invalid THREAD responses.

Benchmarks:

Calculating -------------------------------------
                              v0.4.5-8-g781b44d       0.4.5
invalid_thread_empty_response          114.984k    100.762k i/s -    343.030k times in 2.983283s 3.404345s
      thread_rfc5256_example1            6.313k      5.228k i/s -     19.183k times in 3.038420s 3.669553s
      thread_rfc5256_example2            6.215k      5.090k i/s -     19.153k times in 3.081493s 3.763122s
      thread_rfc5256_example3          112.226k    113.239k i/s -    349.323k times in 3.112662s 3.084841s
      thread_rfc5256_example4           32.746k     26.211k i/s -     97.246k times in 2.969691s 3.710168s
      thread_rfc5256_example5           60.780k     48.940k i/s -    180.990k times in 2.977799s 3.698196s

Comparison:
   invalid_thread_empty_response
  v0.4.5-8-g781b44d:    114984.1 i/s
              0.4.5:    100762.4 i/s - 1.14x  slower

         thread_rfc5256_example1
  v0.4.5-8-g781b44d:      6313.5 i/s
              0.4.5:      5227.6 i/s - 1.21x  slower

         thread_rfc5256_example2
  v0.4.5-8-g781b44d:      6215.5 i/s
              0.4.5:      5089.7 i/s - 1.22x  slower

         thread_rfc5256_example3
              0.4.5:    113238.6 i/s
  v0.4.5-8-g781b44d:    112226.4 i/s - 1.01x  slower

         thread_rfc5256_example4
  v0.4.5-8-g781b44d:     32746.2 i/s
              0.4.5:     26210.7 i/s - 1.25x  slower

         thread_rfc5256_example5
  v0.4.5-8-g781b44d:     60779.8 i/s
              0.4.5:     48940.1 i/s - 1.24x  slower

Note that the only example that was slower (by a statistically insignificant amount), is merely an empty response. All other examples were significantly faster.

Benchmarks:
```
Calculating -------------------------------------
                              v0.4.5-8-g781b44d       0.4.5
invalid_thread_empty_response          114.984k    100.762k i/s -    343.030k times in 2.983283s 3.404345s
      thread_rfc5256_example1            6.313k      5.228k i/s -     19.183k times in 3.038420s 3.669553s
      thread_rfc5256_example2            6.215k      5.090k i/s -     19.153k times in 3.081493s 3.763122s
      thread_rfc5256_example3          112.226k    113.239k i/s -    349.323k times in 3.112662s 3.084841s
      thread_rfc5256_example4           32.746k     26.211k i/s -     97.246k times in 2.969691s 3.710168s
      thread_rfc5256_example5           60.780k     48.940k i/s -    180.990k times in 2.977799s 3.698196s

Comparison:
   invalid_thread_empty_response
  v0.4.5-8-g781b44d:    114984.1 i/s
              0.4.5:    100762.4 i/s - 1.14x  slower

         thread_rfc5256_example1
  v0.4.5-8-g781b44d:      6313.5 i/s
              0.4.5:      5227.6 i/s - 1.21x  slower

         thread_rfc5256_example2
  v0.4.5-8-g781b44d:      6215.5 i/s
              0.4.5:      5089.7 i/s - 1.22x  slower

         thread_rfc5256_example3
              0.4.5:    113238.6 i/s
  v0.4.5-8-g781b44d:    112226.4 i/s - 1.01x  slower

         thread_rfc5256_example4
  v0.4.5-8-g781b44d:     32746.2 i/s
              0.4.5:     26210.7 i/s - 1.25x  slower

         thread_rfc5256_example5
  v0.4.5-8-g781b44d:     60779.8 i/s
              0.4.5:     48940.1 i/s - 1.24x  slower

```

Note that the only example that was slower (by a statistically
insignificant amount), is merely an empty response.  All other examples
were significantly faster.
@nevans nevans merged commit 319ab07 into ruby:master Nov 21, 2023
11 checks passed
@nevans nevans deleted the parser/better-faster-cleaner-THREAD branch November 21, 2023 14:41
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.

1 participant