-
Notifications
You must be signed in to change notification settings - Fork 338
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat:(ast) introduce Value
to support concurrent operations
#573
Closed
Conversation
This file contains 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
Codecov ReportAttention:
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## main #573 +/- ##
==========================================
- Coverage 78.57% 77.60% -0.98%
==========================================
Files 69 70 +1
Lines 10823 11841 +1018
==========================================
+ Hits 8504 9189 +685
- Misses 1942 2138 +196
- Partials 377 514 +137 ☔ View full report in Codecov by Sentry. |
AsterDY
changed the title
feat:(ast) introduce
feat:(ast) introduce Jan 22, 2024
Value
to support concurrently readValue
to support concurrently operations
AsterDY
changed the title
feat:(ast) introduce
feat:(ast) introduce Jan 22, 2024
Value
to support concurrently operationsValue
to support concurrent operations
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.
Background
sonic/ast.Node
provide completed and efficient APIs to manipulate JSON. However, due to itstransversely-lazy-load
design, it CANNOT be read concurrently, result in limited usage in practice -- or abuse usage ofLoadAll()
.Therefore, we consider introduce a new type
ast.Value
, whose APIs are all based on JSONskipping-and-searching
algorithm, can naturally support concurrently readThread Safty
GetXX()
: All read APIs are implemented bysearching-and-skipping
raw JSON, and returned a slice of the origin -- Thus it is thread-safeSetXX()
: All write APIs are implemented based onGetXX()
, and returned a new copy to the origin -- Thus it is false thread-safe, while the correctness of currently-writing need user to ensure by itselfPerformance
Value
's performance is close toNode
, and 3x~10x times faster than the same API ofgjson
|sjson
!!!