bytedance / sonic

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

feat:(ast) `Node` support concurrently-read #661

Open AsterDY opened 2 weeks ago

AsterDY commented 2 weeks ago

Background

Since sonic uses Lazy-Load design to parse JSON nodes on demands, it doesn't support concurrently-Read by default. But in practice, we found many users may use it in such scenarios and cause panic.

Desgin

Thus we design one kind of State Transition Lock to achieve the goal by least cost. In brief:

Performance

codecov-commenter commented 1 week ago

:warning: Please install the 'codecov app svg image' to ensure uploads and comments are reliably processed by Codecov.

Codecov Report

Attention: Patch coverage is 75.70850% with 60 lines in your changes missing coverage. Please review.

Project coverage is 71.58%. Comparing base (99f5b35) to head (95e7de9). Report is 17 commits behind head on main.

Files Patch % Lines
ast/node.go 77.57% 14 Missing and 10 partials :warning:
ast/buffer.go 68.88% 11 Missing and 3 partials :warning:
ast/parser.go 81.66% 9 Missing and 2 partials :warning:
api.go 0.00% 4 Missing :warning:
ast/iterator.go 55.55% 1 Missing and 3 partials :warning:
ast/search.go 70.00% 2 Missing and 1 partial :warning:

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

:exclamation: There is a different number of reports uploaded between BASE (99f5b35) and HEAD (95e7de9). Click for more details.

HEAD has 5 uploads less than BASE | Flag | BASE (99f5b35) | HEAD (95e7de9) | |------|------|------| ||7|2|
Additional details and impacted files ```diff @@ Coverage Diff @@ ## main #661 +/- ## ========================================== - Coverage 77.56% 71.58% -5.98% ========================================== Files 83 101 +18 Lines 11542 8194 -3348 ========================================== - Hits 8952 5866 -3086 + Misses 2192 2012 -180 + Partials 398 316 -82 ```

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