[Study Project] A memory-optimized JSON data structure

This page summarizes the projects mentioned and recommended in the original post on /r/cpp

Our great sponsors
  • WorkOS - The modern identity platform for B2B SaaS
  • InfluxDB - Power Real-Time Data Analytics at Scale
  • SaaSHub - Software Alternatives and Reviews
  • lfjson

    A memory-optimized and data-oriented JSON library written in C++

  • https://github.com/gaujay/lfjson Your mandatory bi-weekly JSON news is here! JK, but let's cut to the chase: this is actually not a new JSON serializer. I wanted to explore some allocator-related topics and noticed (almost) all JSON libraries put emphasis on speed, not memory usage (like in this article).

  • xxHash

    Extremely fast non-cryptographic hash algorithm

  • But what's the catch, you're thinking ? Well, it is a bit slower than its counterparts when it comes to deserializing (and marginally faster for serializing). To achieve smaller footprint, it uses a few tricks and notably a custom hash table to deduplicate strings. This comes at a cost of course (even when featuring xxHash to speed things up), but keeps the slowdown reasonable (I think).

  • WorkOS

    The modern identity platform for B2B SaaS. The APIs are flexible and easy-to-use, supporting authentication, user identity, and complex enterprise features like SSO and SCIM provisioning.

    WorkOS logo
  • glaze

    Extremely fast, in memory, JSON and interface library for modern C++

  • Interesting research. I've been working on a library that reads directly into C++ memory, Glaze, so the JSON library has practically zero heap overhead. You just have the memory cost of your buffer and the C++ that you plan to populate. For example, if you want to read into a `std::map`, then Glaze will pretty much be as efficient in memory cost as the C++ type can store its memory.

  • json

    JSON for Modern C++

  • I think nlohmann-json tried the 'shrink' route but got pretty bad perf penalty for it. For my lib I used the same strategy as RapidJSON and deserialized data in a temp buffer, before mem-copying it to its destination (on reaching array/object end). This is actually faster than trying to manage memory holes created by vector growth.

NOTE: The number of mentions on this list indicates mentions on common posts plus user suggested alternatives. Hence, a higher number means a more popular project.

Suggest a related project

Related posts