-
Notifications
You must be signed in to change notification settings - Fork 14
Serialization Jackson vs. Boon vs. Java Serialization
Most people assume that Java object serialization is faster than Jackson JSON serialization because Jackson is using JSON and Java object serialization is binary. But most people are wrong.
Jackson JSON serialization is much faster than built in Java object serialization.
Boon JSON serialization is much faster than Jackson JSON serialization.
java -jar target/microbenchmarks.jar ".*serialization.*" -wi 2 -i 3 -f 2 -t 16
Testing the Jackson and Boon JSON serializers vs. Java Object serialization.
i.g.j.s.MainBoonSerializer.roundTripBig thrpt 16 6 1 101.708 11.041 ops/s
i.g.j.s.MainJavaSerialization.roundTripBig thrpt 16 6 1 91.339 4.354 ops/s
i.g.j.s.MainJacksonSerializer.roundTripBig thrpt 16 6 1 76.406 2.671 ops/s
Boon wins by 30%. Jackson comes in third. Boon beats Java binary serialization. :)
i.g.j.s.MainBoonSerializer.serializeBig thrpt 16 6 1 377.694 20.544 ops/s
i.g.j.s.MainJavaSerialization.serializeBig thrpt 16 6 1 174.208 23.116 ops/s
i.g.j.s.MainJacksonSerializer.serializeBig thrpt 16 6 1 186.008 16.769 ops/s
Boon wins by 2x.
i.g.j.s.MainBoonSerializer.roundTriper thrpt 16 6 1 312390.819 57581.454 ops/s
i.g.j.s.MainJacksonSerializer.roundTriper thrpt 16 6 1 218978.594 44249.526 ops/s
i.g.j.s.MainJavaSerialization.roundTriper thrpt 16 6 1 47756.764 59303.464 ops/s
Both Boon and Jackson kill Java serialization. Boon also kills Jackson serialization round trip.
i.g.j.s.MainBoonSerializer.serializeSmall thrpt 16 6 1 936352.708 137569.222 ops/s
i.g.j.s.MainJacksonSerializer.serializeSmall thrpt 16 6 1 636723.378 31346.173 ops/s
i.g.j.s.MainJavaSerialization.serializeSmall thrpt 16 6 1 382283.631 25397.336 ops/s
Boon wins by a 30% margin. Jackson comes in second. Both demolish Java built-in serialization.
I recently added some optimizations to Boon JSON serialization 15 (still in snapshot). Let's see what it does to performance.
Benchmark Mode Thr Count Sec Mean Mean error Units
i.g.j.s.MainBoonSerializer.serializeSmall thrpt 16 6 1 928002.808 60950.051 ops/s
i.g.j.s.MainJacksonSerializer.serializeSmall thrpt 16 6 1 611743.833 79255.225 ops/s
i.g.j.s.MainJavaSerialization.serializeSmall thrpt 16 6 1 379509.836 14233.369 ops/s
About the same.
i.g.j.s.MainBoonSerializer.roundTripBig thrpt 16 6 1 96.589 34.860 ops/s
i.g.j.s.MainJavaSerialization.roundTripBig thrpt 16 6 1 87.097 8.706 ops/s
i.g.j.s.MainJacksonSerializer.roundTripBig thrpt 16 6 1 78.378 9.286 ops/s
About the same.
i.g.j.s.MainBoonSerializer.roundTriper thrpt 16 6 1 303601.772 67861.688 ops/s
i.g.j.s.MainJacksonSerializer.roundTriper thrpt 16 6 1 206512.825 9533.699 ops/s
i.g.j.s.MainJavaSerialization.roundTriper thrpt 16 6 1 42197.833 60428.583 ops/s
About the same.
i.g.j.s.MainBoonSerializer.serializeBig thrpt 16 6 1 356.867 28.637 ops/s
i.g.j.s.MainJacksonSerializer.serializeBig thrpt 16 6 1 173.494 24.818 ops/s
i.g.j.s.MainJavaSerialization.serializeBig thrpt 16 6 1 163.283 23.345 ops/s
About the same as before.
In short. Jackson is very fast. Boon is faster. And my latest rounds of optimizations did nothing. :(
Ok.. So I heard a lot about FastJson. https://github.com/alibaba/fastjson/wiki/_pages https://github.com/RuedigerMoeller/fast-serialization/wiki/TestPage Time to pony up to the bar and see how fast FastJSON is....
Round 1.
i.g.j.s.MainBoonSerializer.roundTripBig thrpt 16 3 1 109.539 180.206 ops/s
i.g.j.s.MainFastJsonSerializer.roundTripBig thrpt 16 3 1 77.767 442.537 ops/s
FastJSON comes out swinging. Boon lands a solid punch on the chin send FastJSON back a few steps and FastJSON wonders what just hit him.
Round 2:
i.g.j.s.MainBoonSerializer.roundTriper thrpt 16 3 1 322589.867 263964.706 ops/s
i.g.j.s.MainFastJsonSerializer.roundTriper thrpt 16 3 1 372651.528 60503.278 ops/s
Photo finish, but Boon comes out swinging hard, and FastJSON eeks out a small victory. Time to fire up yourKit and VisualVM.
Round 3
i.g.j.s.MainBoonSerializer.serializeBig thrpt 16 3 1 386.978 52.936 ops/s
i.g.j.s.MainFastJsonSerializer.serializeBig thrpt 16 3 1 143.339 130.480 ops/s
Boon body slams FastJSON. Don't call it a come back. Do you smell what the Boon has been cooking?!
Round 4
i.g.j.s.MainBoonSerializer.serializeSmall thrpt 16 3 1 970575.272 34411.444 ops/s
i.g.j.s.MainFastJsonSerializer.serializeSmall thrpt 16 3 1 784787.311 85672.955 ops/s
Sonic Boon! Allyoucan! Triple twirling punch to the chin. The new world champion in Java JSON serialization. The crowd roars.