Creating the bitmasks for each structural character is very expensive in
ARM due to the lack of pmovmskb similar instructions. Histseg gives us
the number of characters of interest in a single instruction with low
latency and high throughput in neoverse v2 cpus.
This allows us to skip mask creation of characters that are not present
and even to implement some fast path codes when we have only quotes for
example. It is worth noting that x86 doesn’t have an equivalent
instruction and the avx2 VP2INTERSECT instruction doesn’t support int8
datatypes.
Make sure Doxygen 1.8.13 or higher version has been installed. Then following:
mdkir api-doc && cd api-doc
doxygen ../Doxyfile
Design
Sonic-cpp parses JSON into a compact document tree. The document structure is as follows:
There are many optimizations in parsing as follows:
using SIMD to accelerate skipping white space.
using SIMD to find escaped chars when parsing strings.
using the STOA float pointing algorithm.
Sonic-cpp serializes a document to JSON. When serializing JSON strings, we should check the escaped characters first. So, we use SIMD instructions(AVX2/SSE) to find the escaped char for a long JSON string.
Sonic-cpp also supports ParseOnDemand if the user knows the target key at compile time. ParseOndemand also used SIMD and bit manipulation to skip the unwanted values fastly.
Usage
Include
Sonic-Cpp is a header-only library, you only need to include the directory of
Sonic-Cpp header files, such as adding -I/path/to/sonic/include/ to your
compiler.
Sonic-Cpp
A fast JSON serializing & deserializing library, accelerated by SIMD.
Requirement
Features
Benchmarks
use CMake
use bazel
Performance by sonic benchmark
Parsing Performance
Serializing performance
Performance by third-party benchmark
Below data is test by https://github.com/miloyip/nativejson-benchmark:
Parsing Performance
Serializing Performance
API Document
Make sure Doxygen 1.8.13 or higher version has been installed. Then following:
Design
Sonic-cpp parses JSON into a compact document tree. The document structure is as follows:
There are many optimizations in parsing as follows:
Sonic-cpp serializes a document to JSON. When serializing JSON strings, we should check the escaped characters first. So, we use SIMD instructions(AVX2/SSE) to find the escaped char for a long JSON string.
Sonic-cpp also supports ParseOnDemand if the user knows the target key at compile time. ParseOndemand also used SIMD and bit manipulation to skip the unwanted values fastly.
Usage
Include
Sonic-Cpp is a header-only library, you only need to include the directory of Sonic-Cpp header files, such as adding
-I/path/to/sonic/include/to your compiler.Parsing and Serializing
Checking parse result
Getting and Setting
The following Is*, Get* and Set* methods are supported:
More usage.
RoadMap
RawNumberfor JSON parsing.JSON Path.JSON Merge Patch.JSON Pointer.Contributing
Please read CONTRIBUTING.md for information on contributing to sonic-cpp.