Serde and serde_json 1.0.0 released

I finally updated our nativejson benchmark suite to Serde 1.0. This is the same suite that is tested across dozens of C and C++ libraries in this repo.

Here is serde_json compared to the fastest C or C++ JSON library. Lower numbers are better.

                                DOM                STRUCT
======= serde_json ======= parse|stringify === parse|stringify ===
data/canada.json          10.2ms    11.1ms     4.2ms     6.9ms
data/citm_catalog.json     5.3ms     1.3ms     2.1ms     0.8ms
data/twitter.json          2.5ms     0.6ms     1.3ms     0.6ms

==== rapidjson-clang ===== parse|stringify ===
data/canada.json           5.7ms    10.5ms
data/citm_catalog.json     2.5ms     1.7ms
data/twitter.json          1.8ms     1.2ms

===== rapidjson-gcc ====== parse|stringify ===
data/canada.json           4.7ms     8.6ms
data/citm_catalog.json     1.7ms     1.0ms
data/twitter.json          1.3ms     0.7ms

Note that the STRUCT columns are missing for rapidjson because, while it supports SAX style parsing, the approach is such that it is totally unreasonable to use it for real use cases. To prove it, compare Serde's 3 structs and an enum here vs RapidJSON's 400 line error-prone handwritten state machine here.

The benchmarks show that our DOM (which means serde_json::Value) is not as good at parsing. It is a factor of 1.5-2 slower than rapidjson-clang, and a factor of 2-3 slower than rapidjson-gcc. On the printing side it is much closer and even twice as fast as rapidjson-clang on one of the benchmark files and slightly faster than rapidjson-gcc. So as always, any decisions you make should be based on benchmarks of your own representative data.

So that's good but not great. Keep in mind that RapidJSON is the fastest C or C++ library on these specific benchmark files. Most successful C and C++ JSON libraries are slower by a factor of 10.

But a more realistic comparison is what people actually use, and in Serde that means #[derive(Serialize, Deserialize)]. Comparing that column, you can see that Serde serialization is substantially faster across all three files, whether compiling RapidJSON with Clang or GCC. Serde serialization is more than twice as fast in some use cases. Serde deserialization is noticeably faster than rapidjson-clang and on par with rapidjson-gcc. That's pretty remarkable.

Note that these numbers are just using basic Serde 1.0 and serde_json 1.0 without the new zero-copy feature.

40 Likes