In age of remakes, sequels, reboots and such things I decided to make my own :) 6 years ago I wrote a pretty big blog post about Scala Serialization. I received some positive feedback and some proposal - which libraries to include to benchmark. I wanted to follow up on it for a long time, but… didn’t have enough time and motivation to go back. And now it’s time :)
In our era of Internet, JSON is probably the most used data format. It makes the choice of the library to work with JSON (or any other data format) pretty much important: CPU cycles spent on serialization/deserialization may save your bill and environment.
Even though the focus of this benchmark is on Scala libraries, I actually benchmark 50/50 Scala and Java libraries.
Data Formats and Libraries
A full list of formats and libraries in benchmark:
- JSON format: Jackson, Jsoniter, uPickle and Circe.
- Protocol Buffers (protobuf): ScalaPB and protobuf-java.
- Thrift: libthrift.
- MessagePack: uPickle.
- Cap’n Proto: capnproto-java.
- Boopickle. Custom binary format without backward-compatibility.
- Kryo: Chill.
- CBOR and Smile via Jackson.
- Java serialization just for reference.
I dropped few libraries that I benchmarked previously:
- kryo-macros: it’s not maintained, apparently, the library was published on bintray, which is shutdown.
- Scrooge: doesn’t work with
libthrift
greater than0.10.0
. - pickling: repo is archived, last version is for scala-library
2.11
.
Data Model
TBD: Why is it important that I use DTO and events?
Performance
Charts!
Data Size
Table, charts!
Conclusion
Extra
Read More
- Amazing and rich benchmarks by jsoniter-scala.
- JVM Serializers
Play with charts here, data sizes tables. Source code is on GitHub. Originally posted on Medium. Cover image by from Pixabay.