ffi: Add support to serialize msgpack array/map into a JSON string.#465
Open
LinZhihao-723 wants to merge 2 commits into
Open
ffi: Add support to serialize msgpack array/map into a JSON string.#465LinZhihao-723 wants to merge 2 commits into
LinZhihao-723 wants to merge 2 commits into
Conversation
LinZhihao-723
commented
Jun 28, 2024
| // Recursively create inner maps and arrays | ||
| // Note: the execution time and memory consumption will grow exponentially as we increase the | ||
| // recursive depth. | ||
| constexpr size_t cRecursiveDepth{6}; |
Member
Author
There was a problem hiding this comment.
This depth is chosen to not take too long. Depth == 6 takes 3 seconds on my laptop, whereas Depth == 7 takes 25 seconds (which might be too long).
Member
|
Can you resolve the conflicts? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
In the next IR stream format, we use
msgpackto represent a structured log event before CLP IR serialization. To handle the arrays inside the structured log event, we store them as unstructured arrays represented by a JSON string (same asclp-s). This requires methods to turn a msgpack object into JSON string. There are two existing ways to do this:nlohmann JSONlibrary provides this feature by turning the msgpack bytes into an in-memory JSON object and then dumping the object into a raw string. However, from our experimental benchmark, this introduces significant run time overhead. It's more efficient to directly turn amsgpackin-memory objects into JSON string.<<operator on an in-memorymsgpackobject will also return a JSON string: [https://github.com/msgpack/msgpack-c/wiki/v_2_0_cpp_json].This PR adds methods to support serialization from
msgpackarray/map to JSON string without turning it into other intermediate representations. Even thoughmsgpack-calready has support on JSON serialization, a microbenchmark shows that our implementation is 3 times faster than using<<.Validation performed