# Faster JSON serialization, simdjson

**URL:** <https://discourse.mc-stan.org/t/faster-json-serialization-simdjson/14190>\
**Category:** Developers\
**Created:** [April 8, 2020, 2:04pm UTC](https://discourse.mc-stan.org/t/faster-json-serialization-simdjson/14190 "2020-04-08T14:04:26Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![ariddell](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@ariddell](https://discourse.mc-stan.org/u/ariddell)\
**Post date:** [April 8, 2020, 2:04pm UTC](https://discourse.mc-stan.org/t/faster-json-serialization-simdjson/14190/1 "2020-04-08T14:04:26Z")

</div>

Looks like there’s a new json library that’s far faster than rapidjson, [https://github.com/simdjson/simdjson](https://github.com/simdjson/simdjson) It’s reportedly 8.6 times faster than rapidjson.

I wonder how much slower this is than using binary serialization. In switching to protobuf, httpstan saw a ~30% increase in speed over ujson. But perhaps the speedup would have been marginal had we been using simdjson. Impressive!

Related to previous discussion here: [Notes on Stan Output Serialization Options (YAML, Protobuf, Avro, CBOR)](https://discourse.mc-stan.org/t/notes-on-stan-output-serialization-options-yaml-protobuf-avro-cbor/12837)

---

<div class="post-metadata">

**Author:** ![rok\_cesnovar](https://avatars.discourse-cdn.com/v4/letter/r/7bcc69/32.png) [@rok\_cesnovar](https://discourse.mc-stan.org/u/rok_cesnovar)\
**Post date:** [April 8, 2020, 2:13pm UTC](https://discourse.mc-stan.org/t/faster-json-serialization-simdjson/14190/2 "2020-04-08T14:13:42Z")

</div>

Yep, simdjson is lightning fast and I looked at it when working on cmdstan JSON parser change.  
However, its currently not suitable for cmdstan due to the C++17 requirement.

---

<div class="post-metadata">

**Author:** ![ariddell](https://avatars.discourse-cdn.com/v4/letter/a/57b2e6/32.png) [@ariddell](https://discourse.mc-stan.org/u/ariddell)\
**Post date:** [April 8, 2020, 2:19pm UTC](https://discourse.mc-stan.org/t/faster-json-serialization-simdjson/14190/3 "2020-04-08T14:19:37Z")

</div>

That makes sense.

I probably should have used “deserialization” in the title. I was thinking about how simdjson might change some of our thinking about the suitability of JSON as a storage format for output. That is, if simdjson makes reading large fits really fast, we would have less pressure to consider formats like HDF or Apache Arrow, etc.

---

<div class="post-metadata">

**Author:** ![Bob\_Carpenter](https://yyz2.discourse-cdn.com/flex030/user_avatar/discourse.mc-stan.org/bob_carpenter/32/9230_2.png) [@Bob\_Carpenter](https://discourse.mc-stan.org/u/Bob_Carpenter)\
**Post date:** [April 9, 2020, 9:56pm UTC](https://discourse.mc-stan.org/t/faster-json-serialization-simdjson/14190/4 "2020-04-09T21:56:51Z")

</div>

There’s also size. JSON files will be more than twice as big if they’re at 16-digit precision compared to binary (there’s also the `-` and `.` and `e` symbols).
