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.
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
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. 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. 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. 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. 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. 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
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. 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.
22. 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
23.
24. • Boon JSON support is also really good at doing
weird JSON encoding.
25.
26. • 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.