Oj: OPTIMIZED JSON
Ryan Perrin
Brandon Weaver
What is Oj?

It is not...
ORange Juice...

Jerks...
It is:
A JSON parser/serializer/deserializer.
A C extension to Ruby.
Pitched as being significantly faster than other parsers.
Why Oj over JSON?
Doesn't have many of the inefficiencies that JSON has:
Doesn't parse JSON into Ruby Objects.
Doesn't rely on the Ruby GC for cleanup.
Also: Did I mention it is fast?!
Benchmarks
We've spent time speaking to how good Oj is.
How good is good?
Other Alternatives
JSON
JSON_Pure
YAJL
Scope of Upgrade
Involves changing all JSON.parse to Oj.load.
Use oj_mimic_json gem (Rails 4.1).
Some test fixes.
Abstraction with Multi_Json
Multi_json provides an abstraction layer for JSON parsers.
Allows the developer to switch out adapters easily and without many code changes.
Uses JSON, gem in Gemfile or manually configured adapter.
Unfortunately: Reduction in performance.
Useful Links
oj: https://github.com/ohler55/oj
multi_json: https://github.com/intridea/multi_json
Benchpress: https://github.com/baweaver/Benchpress
Questions?

Deserialization Timings
Sizes: 1.9, 22.3, 44.4, 71.2mb
JSON.parse

Oj.load (mode: :compat)

What does it all mean!?
On average, Oj is:
~10% faster than JSON for smaller files.
~7.5% faster for larger files.
Or, for those who don't like math:
Between 25-700ms faster.
This may not seem like much, but...
Impact Over Time
Size: 65mb

Oj.
By Ryan Perrin
Oj.
- 607