feat: add high-performance Compact API (#778)#889
Open
blueberrycongee wants to merge 1 commit intobytedance:mainfrom
Open
feat: add high-performance Compact API (#778)#889blueberrycongee wants to merge 1 commit intobytedance:mainfrom
blueberrycongee wants to merge 1 commit intobytedance:mainfrom
Conversation
- Add sonic.Compact() as analog of json.Compact - Implement fast compaction in internal/encoder/prim - Add compat fallback using encoding/json for non-amd64/arm64 - Add comprehensive unit tests and benchmarks Benchmark results (vs encoding/json.Compact): - Large JSON: ~64% faster (406 MB/s vs 248 MB/s) - Small JSON: ~43% faster (229 MB/s vs 160 MB/s) Closes bytedance#778
This file contains hidden or 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
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.
What type of PR is this?
feat: A new feature
Check the PR title.
(Optional) Translate the PR title into Chinese.
feat: 添加高性能 Compact API
(Optional) More detailed description for this PR
en:
Add sonic.Compact() as a high-performance analog of json.Compact. This function removes insignificant whitespace from JSON-encoded data.
Changes:
internal/encoder/primwith optimized string/escape handlingencoding/jsonfor non-amd64/arm64 platformsBenchmark results (vs encoding/json.Compact):
zh:
添加 sonic.Compact() 作为 json.Compact 的高性能替代。大 JSON 性能提升约 64%,小 JSON 提升约 43%。
(Optional) Which issue(s) this PR fixes:
Fixes #778
(optional) The PR that updates user documentation:
N/A (API is straightforward drop-in replacement for json.Compact)