bytedance / sonic

A blazingly fast JSON serializing & deserializing library
Apache License 2.0
6.59k stars 327 forks source link

feat: introduce `ast.Value` to support read and write concurrently #579

Closed AsterDY closed 4 months ago

AsterDY commented 6 months ago

Background

sonic/ast.Node provide completed and efficient APIs to manipulate JSON. However, due to its transversely-lazy-load design, it CANNOT be read concurrently, result in limited usage in practice -- or abuse usage of LoadAll(). Therefore, we consider introduce a new type ast.Value, whose APIs are all based on JSON skipping-and-searching algorithm, can naturally support concurrently read

Thread Safty

Performance

Value's performance is close to Node, and 3x~10x times faster than the same API of gjson|sjson!!!

codecov-commenter commented 6 months ago

Codecov Report

Attention: Patch coverage is 58.84808% with 493 lines in your changes are missing coverage. Please review.

Project coverage is 76.63%. Comparing base (3739ffe) to head (bbf63a6).

Files Patch % Lines
ast/raw.go 64.67% 194 Missing and 102 partials :warning:
ast/decode.go 0.00% 52 Missing :warning:
ast/parser.go 66.01% 43 Missing and 9 partials :warning:
ast/search.go 25.37% 44 Missing and 6 partials :warning:
ast/api_amd64.go 57.44% 16 Missing and 4 partials :warning:
api.go 14.28% 18 Missing :warning:
internal/rt/fastmem.go 0.00% 4 Missing :warning:
ast/visitor.go 50.00% 1 Missing :warning:

:exclamation: Your organization needs to install the Codecov GitHub app to enable full functionality.

Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #579 +/- ## ========================================== - Coverage 77.56% 76.63% -0.93% ========================================== Files 83 84 +1 Lines 11542 12581 +1039 ========================================== + Hits 8952 9642 +690 - Misses 2192 2408 +216 - Partials 398 531 +133 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.