Replies: 1 comment
-
Hm, actually RapidJSON might be more of an option than I initially thought too. I used it once long ago, and it was fast but had a really rough interface. Now the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
This is the promised issue for json library discussion, copying in @milroy and @garlick from the qmanager stats PR. I have data in case anyone is interested. I took a copy of the nativejson-benchmark by miloyip and made it work with gcc 14 and current versions of the various libraries that make sense (minus folly, not sure why but that test just wont run) and ran up the full suite. I also created a protobuf file and a structure to represent a JGF R to use the Protobuf3 canonical json support and glaze automatic structure (de)serialization for parse and stringify, the other benchmarks don't really apply to those because they only do a complete object rather than streaming parsing. If you want to look at everything, the whole website generated by the benchmark, including tables of precise numbers, is here:
result.zip
Here are the major results, largely influenced by a 400mb json file courtesy of @jameshcorbett. The 800mb one @grondo recommended ran my VM out of memory (it's only provisioned 14GB).
Updated to add results for parse and serialize to binary formats for glaze, proto3, and nlohmann. Why anyone uses protobufs is now beyond me...
In terms of performance, if we can use the structured parsing, then glaze wins by a good bit compared to the other ones that we could reasonably use. Sadly nlohmann/json, which is the nicest to use with unknown values and supports the most formats, is pretty slow for parsing. That might be improved by making it use a flat_map, but that proved difficult. Surprising to me is that the protobuf json support is so slow. I suppose if we used the actual protobuf binary format it would be much faster, but did not test that. I think I'm leaning toward either Boost::Json or Glaze, the main tradeoff between these is that glaze's current versions require C++23, and thus g++>=12 clang>=15. It looks like all our supported images have at least that, so maybe that's ok, but it's worth considering. The compile time and memory use of Boost::Json is better than that of glaze without having compile-time structure information as well, so there's that. The jansson stringify performance and memory overhead with large json were big surprises as well.
Just so you can get an idea, here's the actual structured glaze code I used for testing:
Structured glaze code
Beta Was this translation helpful? Give feedback.
All reactions