This option is used to cache parsed simple paths and search JSON path all-in-once in C funtions, to reduce the overhead of c-go interaction. By default, this option is disabled, because it will and consumes a little more memory than default. You can enable it by set environment variable GJSON_FAST_PATH=1.
FastString
By default, Gjson doesn’t use the SIMD algorithm when decoding a string and does not validate UTF8 either, thus its string-value APIs’ behaviors are slow and different from encoding/json. You can change the behaviors by setting the environment variable below:
GJSON_FAST_STRING=1: SIMD-implemented string parsing. The string-value APIs’ behaviors will be the same as sonic/decoder’s default behavior, with 2~3X times the speed of default string-parsing.
GJSON_FAST_STRING=2, SIMD-implemented string parsing, and UTF-8 validating. String-value APIs’ behaviors will be totally same with encoding/json.Decode and also faster than the default.
Benchmark
This is a benchmark on the above options (see codes):
GJSON
This is a wrapper lib of gjson, which is accelerated by sonic‘s algorithm.
Performance
It’s usually faster than original one, especially for large JSON. (see codes here)
Options
FastPath
This option is used to cache parsed simple paths and search JSON path all-in-once in C funtions, to reduce the overhead of c-go interaction. By default, this option is disabled, because it will and consumes a little more memory than default. You can enable it by set environment variable
GJSON_FAST_PATH=1.FastString
By default, Gjson doesn’t use the SIMD algorithm when decoding a string and does not validate UTF8 either, thus its string-value APIs’ behaviors are slow and different from
encoding/json. You can change the behaviors by setting the environment variable below:GJSON_FAST_STRING=1:SIMD-implementedstring parsing. The string-value APIs’ behaviors will be the same as sonic/decoder’s default behavior, with 2~3X times the speed of default string-parsing.GJSON_FAST_STRING=2,SIMD-implementedstring parsing, and UTF-8 validating. String-value APIs’ behaviors will be totally same withencoding/json.Decodeand also faster than the default.Benchmark
This is a benchmark on the above options (see codes):