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

Optimize JSON::Pure::Generator by 2x-4x for simple options cases #586

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

eregon
Copy link
Contributor

@eregon eregon commented May 9, 2024

* ruby --yjit benchmarks/bench.rb dump pure ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [x86_64-linux]
  Before: JSON.dump(obj)    604.604  (± 0.3%) i/s    (1.65 ms/i) -      3.060k in   5.061200s
  After:  JSON.dump(obj)      2.531k (± 0.4%) i/s  (395.14 μs/i) -     12.801k in   5.058326s
* ruby benchmarks/bench.rb dump pure
  truffleruby 24.1.0-dev-a8ebb51b, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-linux]
  Before: JSON.dump(obj)      3.728k (± 9.4%) i/s  (268.26 μs/i) -     18.559k in   5.068915s
  After:  JSON.dump(obj)      7.835k (± 8.5%) i/s  (127.63 μs/i) -     39.004k in   5.031116s

Using the benchmark from #580

BTW, the C extension, with YJIT gives:

JSON::Ext::Generator
ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [x86_64-linux]
JSON.dump(obj)      7.402k (± 1.0%) i/s  (135.10 μs/i) -     37.485k in   5.064832s

@eregon eregon force-pushed the optimize-ruby-generator branch 2 times, most recently from eabc779 to 0dee779 Compare May 9, 2024 16:14
* ruby --yjit benchmarks/bench.rb dump pure
  ruby 3.3.1 (2024-04-23 revision c56cd86388) +YJIT [x86_64-linux]
  Before: JSON.dump(obj)    604.604  (± 0.3%) i/s    (1.65 ms/i) -      3.060k in   5.061200s
  After:  JSON.dump(obj)      2.531k (± 0.4%) i/s  (395.14 μs/i) -     12.801k in   5.058326s
* ruby benchmarks/bench.rb dump pure
  truffleruby 24.1.0-dev-a8ebb51b, like ruby 3.2.2, Oracle GraalVM JVM [x86_64-linux]
  Before: JSON.dump(obj)      3.728k (± 9.4%) i/s  (268.26 μs/i) -     18.559k in   5.068915s
  After:  JSON.dump(obj)      7.835k (± 8.5%) i/s  (127.63 μs/i) -     39.004k in   5.031116s
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.

None yet

1 participant