-
Notifications
You must be signed in to change notification settings - Fork 3
Closed
Description
MultiJSON tries to have intelligent defaulting. […] When loading, libraries are ordered by speed. First fast_jsonparser, then Oj, then Yajl, then the JSON gem. If no other JSON library is available, MultiJSON falls back to OkJson, a simple, vendorable JSON parser.
Is this order still correct?
The vanilla JSON gem is pretty fast these days, since a lot of effort has been spent optimizing it by the performance wizard byroot over the past year (see links below).
== Parsing twitter.json (567916 bytes)
ruby 3.4.1 (2024-12-25 revision 48d4efcb85) +YJIT +PRISM [arm64-darwin23]
Warming up --------------------------------------
json 93.000 i/100ms
oj 66.000 i/100ms
Oj::Parser 80.000 i/100ms
rapidjson 58.000 i/100ms
Calculating -------------------------------------
json 928.472 (± 0.3%) i/s (1.08 ms/i) - 4.650k in 5.008282s
oj 666.198 (± 0.8%) i/s (1.50 ms/i) - 3.366k in 5.052899s
Oj::Parser 803.031 (± 0.2%) i/s (1.25 ms/i) - 4.080k in 5.080788s
rapidjson 584.869 (± 0.2%) i/s (1.71 ms/i) - 2.958k in 5.057565s
Comparison:
json: 928.5 i/s
Oj::Parser: 803.0 i/s - 1.16x slower
oj: 666.2 i/s - 1.39x slower
rapidjson: 584.9 i/s - 1.59x slower
Links
- https://oldmoe.blog/2025/04/21/ruby-data-serialization-options-in-2025/
- https://byroot.github.io/ruby/json/2024/12/15/optimizing-ruby-json-part-1.html
- https://byroot.github.io/ruby/json/2024/12/18/optimizing-ruby-json-part-2.html
- https://byroot.github.io/ruby/json/2024/12/27/optimizing-ruby-json-part-3.html
- https://byroot.github.io/ruby/json/2024/12/29/optimizing-ruby-json-part-4.html
- https://byroot.github.io/ruby/json/2025/01/04/optimizing-ruby-json-part-5.html
- https://byroot.github.io/ruby/json/2025/01/12/optimizing-ruby-json-part-6.html
- https://byroot.github.io/ruby/json/2025/01/14/optimizing-ruby-json-part-7.html
sandstrom and nevans
Metadata
Metadata
Assignees
Labels
No labels