Java JSON Parser
Benchmarks
Rick Hightower
• Java Boon - Benchmarks
• Boon comes with a fast JSON parser. This parser
was forked / merged into Groovy 2.3. The Boon a...
How much faster?
Benchmark uses JMH
• JMH is what OpenJDK uses
• We used json files from json.org for parsing
Environment
• Environment
• OSX MacBook Pro, JDK 1.7, 16GB RAM and
512GB SSD drive
Summary
• Jackson is consistently faster than GSON and JSONSmart.
• Boon JSON parser is faster than Jackson with Reader, r...
FAQ 1
• Why don't you test GSON and JSONSmart?Jackson
is faster than GSON and JSONSmart. We have
tests for all four. We on...
FAQ 2
• Why don't you test Jackson AST?
• We do. We see no real difference between readTree
and readValue. We left out AST...
Who wrote benchmarks?
• Who wrote the benchmarks?
• They first version was written by Stephane
Landelle of Gatling fame an...
Relationship to Groovy
JSON parser for 2.3?
• Andrey Bloschetsov and Rick Hightower, with the help of the Groovy lead
deve...
Are the benchmarks flawed and do
they allow JIT dead code elimination?
• Unlikely
• The benchmark uses JMH. JMH is what th...
JMH BlackHole
JMH BlackHole
Allows no DEAD CODE JIT
ELIMINATION
Running JMH
• For most tests parser are warmed up after two
JMH runs. For some tests Jackson needed a few
more warmups and...
Boon JSON Caveats
• Boon JSON parser is a parser optimized for REST and WebSocket style services.
• Boon JSON parser is op...
JSON from Files
JSON from InputStream
Object Serialization
• Java Boon and Jackson are faster than Java
ObjectOutputStream and ObjectInputStream
• Java Boon is ...
• Boon JSON support is also really good at doing
weird JSON encoding.
• Why Boon?
• Easily read in files into lines or a giant string with one
method call. Works with files, URLs, class-path, ...
Why Faster?
Why Faster? Continued
Java JSON Benchmark
Java JSON Benchmark
Java JSON Benchmark
Java JSON Benchmark
Java JSON Benchmark
Upcoming SlideShare
Loading in...5
×

Java JSON Benchmark

3,465

Published on

Groovy JSON support and the Boon JSON parser are up to 3x to 5x faster than Jackson at parsing JSON from String and char[], and 2x to 4x faster at parsing byte[].

Groovy JSON support and Boon JSON support are also faster than Jackson at encoding JSON strings. Boon is faster than Jackson at serializing/de-serializing Java instances to/fro JSON. The core of the Boon JSON parser has been forked into Groovy 2.3 (now in Beta). In the process Boon JSON support was improved and further enhanced. Groovy and Boon JSON parsers speeds are equivalent. Groovy now has the fastest JSON parser on the JVM.

Published in: Technology
0 Comments
10 Likes
Statistics
Notes
  • Be the first to comment

No Downloads
Views
Total Views
3,465
On Slideshare
0
From Embeds
0
Number of Embeds
3
Actions
Shares
0
Downloads
23
Comments
0
Likes
10
Embeds 0
No embeds

No notes for slide

Java JSON Benchmark

  1. 1. Java JSON Parser Benchmarks Rick Hightower
  2. 2. • Java Boon - Benchmarks • Boon comes with a fast JSON parser. This parser was forked / merged into Groovy 2.3. The Boon and Groovy 2.3 JSON parsers are a lot faster than mainstream JSON parsers. • "Rick / Andrey duo spent a fair amount of time optimizing our JSON support, making Groovy 2.3’s JSON support usually faster than all the JSON libraries available in the Java ecosystem." -- Guillaume Laforge
  3. 3. How much faster?
  4. 4. Benchmark uses JMH • JMH is what OpenJDK uses • We used json files from json.org for parsing
  5. 5. Environment • Environment • OSX MacBook Pro, JDK 1.7, 16GB RAM and 512GB SSD drive
  6. 6. Summary • Jackson is consistently faster than GSON and JSONSmart. • Boon JSON parser is faster than Jackson with Reader, reading files, byte[], and char[] and String. • Boon is 3x to 5x faster than Jackson at parsing JSON from String and char[], and 2x to 4x faster at parsing byte[] • Boon and Jackson speeds are much closer with InputStream based parsing. Boon is usually faster at InputStream, but the margins are much smaller. • Boon and Jackson are close at handling InputStream if the JSON stream is small. Once the JSON stream gets over 1KB to 2KB, Boon wins consistently. • Boon is faster at encoding JSON strings, and serializing/de-serializing Java instances to/from JSON than Jackson.
  7. 7. FAQ 1 • Why don't you test GSON and JSONSmart?Jackson is faster than GSON and JSONSmart. We have tests for all four. We only included the tests for Jackson because Jackson is faster than the other two. Anyone can download the benchmark and run all of the tests.
  8. 8. FAQ 2 • Why don't you test Jackson AST? • We do. We see no real difference between readTree and readValue. We left out AST because it is redundant. The tests are still there and easy to run. AST +/- 10% of non AST usually +/- 5%.
  9. 9. Who wrote benchmarks? • Who wrote the benchmarks? • They first version was written by Stephane Landelle of Gatling fame and performance expert • Later they were added to by Andrey Bloschetsov for Groovy serialization • Rick Hightower added new tests as well
  10. 10. Relationship to Groovy JSON parser for 2.3? • Andrey Bloschetsov and Rick Hightower, with the help of the Groovy lead developers, took the Boon classes mostly written by Hightower and forked them into Groovy 2.3 • Mainly for parsing, but we also improved the JSON serialization speed • Boon and Groovy parsing are unsurprisingly very comparable • Groovy JSON parsing is a bit faster in a few use cases, and Boon parser is a bit faster in a few uses cases, but mostly they are neck in neck • Boon JSON de-serialization (from JSON into instances of Classes) is still quite a bit faster than Groovy. This will change in Groovy 2.4 or 2.5 • The new Groovy JSON parser based on Boon is 20x faster than the Groovy 2.2 parser
  11. 11. Are the benchmarks flawed and do they allow JIT dead code elimination? • Unlikely • The benchmark uses JMH. JMH is what the OpenJDK uses for benchmarking. JMH endeavors to eliminate JIT dead code elimination. • See full benchmarks here (https://github.com/RichardHightower/json-parsers- benchmark/blob/master/README.md) 11
  12. 12. JMH BlackHole
  13. 13. JMH BlackHole
  14. 14. Allows no DEAD CODE JIT ELIMINATION
  15. 15. Running JMH • For most tests parser are warmed up after two JMH runs. For some tests Jackson needed a few more warmups and it was accommodated with extra warmup time
  16. 16. Boon JSON Caveats • Boon JSON parser is a parser optimized for REST and WebSocket style services. • Boon JSON parser is optimized to work in a reactive style environment like Akka, Vert.x, etc. Boon JSON parser would work well with MessageDrivenBeans (EJB or Spring). • For some use cases it runs stateless faster than Jackson runs with shared buffers. • Jackson can handle very large JSON files and very large JSON streams. This support was added to Boon JSON as part of the fork/port to Groovy JSON. With larger files the speeds are much more equivalent, and in fact Jackson might be 10% faster or so. • Benchmark first. • It would take some extra effort to get superior results in a Servlet environment (it can be done). • Jackson is mature and solid. Don't assume ripping out Jackson for Boon will buy you anything. Jackson has tooling that makes it work really well in a Java EE environment, and is more fool proof.
  17. 17. JSON from Files
  18. 18. JSON from InputStream
  19. 19. Object Serialization • Java Boon and Jackson are faster than Java ObjectOutputStream and ObjectInputStream • Java Boon is 85% of the speed of Kryo which is the fastest binary serializer
  20. 20. • Boon JSON support is also really good at doing weird JSON encoding.
  21. 21. • Why Boon? • Easily read in files into lines or a giant string with one method call. Works with files, URLs, class-path, etc. Boon IO support will surprise you how easy it is. Boon has Slice notation for dealing with Strings, Lists, primitive arrays, Tree Maps, etc. If you are from Groovy land, Ruby land, Python land, or whatever land, and you have to use Java then Boon might give you some relief from API bloat. If you are like me, and you like to use Java, then Boon is for you too. Boon lets Java be Java, but adds the missing productive APIs from Python, Ruby, and Groovy. Boon may not be Ruby or Groovy, but its a real Boon to Java development.
  22. 22. Why Faster?
  23. 23. Why Faster? Continued
  1. A particular slide catching your eye?

    Clipping is a handy way to collect important slides you want to go back to later.

×