Skip to content
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

opt: add decoder Option NoValidateJSON for skipping JSON faster #696

Merged
merged 22 commits into from
Sep 13, 2024

Conversation

AsterDY
Copy link
Collaborator

@AsterDY AsterDY commented Aug 26, 2024

Background

By default, sonic uses FSM algorithm to skip unnecessary JSON parsing, but it's much slower than SIMD-fast-skipping. Thus we introduce an Option NoValidateJSON to boost cases such as :

  • Mismatched-type values
  • Unknown fields
  • Omitted fields
  • Empty struct
  • Redundant array elements
  • json.Unmarshaler (json.RawMessage)

Performance

In x86, the fast-skipping is 5x times fast when handling complicated JSON value like TwitterJSON

goos: linux
goarch: amd64
pkg: github.com/bytedance/sonic/decoder
cpu: Intel(R) Xeon(R) Platinum 8260 CPU @ 2.40GHz
BenchmarkSkipValidate/mismatched-field/validate-32                114846             10841 ns/op
BenchmarkSkipValidate/mismatched-field/fast-32                    878814              1172 ns/op
BenchmarkSkipValidate/ommited-field/validate-32                   110401             11003 ns/op
BenchmarkSkipValidate/ommited-field/fast-32                      1000000              1073 ns/op
BenchmarkSkipValidate/redundant-array/validate-32                  52734             22754 ns/op
BenchmarkSkipValidate/redundant-array/fast-32                     111651             11742 ns/op
BenchmarkSkipValidate/unknown-field/validate-32                    97878             10872 ns/op
BenchmarkSkipValidate/unknown-field/fast-32                      1000000              1150 ns/op
BenchmarkSkipValidate/empty-struct/validate-32                    115086             11182 ns/op
BenchmarkSkipValidate/empty-struct/fast-32                       1000000              1147 ns/op
BenchmarkSkipValidate/mismatched-elem/validate-32                 104296             12210 ns/op
BenchmarkSkipValidate/mismatched-elem/fast-32                     758089              1458 ns/op

liuq19
liuq19 previously approved these changes Aug 27, 2024
@AsterDY AsterDY merged commit edc70ff into main Sep 13, 2024
49 checks passed
@AsterDY AsterDY deleted the opt/decoder_skip branch September 13, 2024 07:46
dmathieu referenced this pull request in open-telemetry/opentelemetry-go-contrib Sep 23, 2024
This PR contains the following updates:

| Package | Change | Age | Adoption | Passing | Confidence |
|---|---|---|---|---|---|
|
[github.com/bytedance/sonic](https://redirect.github.com/bytedance/sonic)
| `v1.12.2` -> `v1.12.3` |
[![age](https://developer.mend.io/api/mc/badges/age/go/github.com%2fbytedance%2fsonic/v1.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![adoption](https://developer.mend.io/api/mc/badges/adoption/go/github.com%2fbytedance%2fsonic/v1.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![passing](https://developer.mend.io/api/mc/badges/compatibility/go/github.com%2fbytedance%2fsonic/v1.12.2/v1.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|
[![confidence](https://developer.mend.io/api/mc/badges/confidence/go/github.com%2fbytedance%2fsonic/v1.12.2/v1.12.3?slim=true)](https://docs.renovatebot.com/merge-confidence/)
|

---

### Release Notes

<details>
<summary>bytedance/sonic (github.com/bytedance/sonic)</summary>

###
[`v1.12.3`](https://redirect.github.com/bytedance/sonic/releases/tag/v1.12.3)

[Compare
Source](https://redirect.github.com/bytedance/sonic/compare/v1.12.2...v1.12.3)

#### What's Changed

- opt: add decoder Option `NoValidateJSON` for skipping JSON faster by
[@&#8203;AsterDY](https://redirect.github.com/AsterDY) in
[https://github.com/bytedance/sonic/pull/696](https://redirect.github.com/bytedance/sonic/pull/696)

**Full Changelog**:
bytedance/sonic@v1.12.2...v1.12.3

</details>

---

### Configuration

📅 **Schedule**: Branch creation - At any time (no schedule defined),
Automerge - At any time (no schedule defined).

🚦 **Automerge**: Disabled by config. Please merge this manually once you
are satisfied.

♻ **Rebasing**: Whenever PR becomes conflicted, or you tick the
rebase/retry checkbox.

🔕 **Ignore**: Close this PR and you won't be reminded about this update
again.

---

- [ ] <!-- rebase-check -->If you want to rebase/retry this PR, check
this box

---

This PR was generated by [Mend Renovate](https://mend.io/renovate/).
View the [repository job
log](https://developer.mend.io/github/open-telemetry/opentelemetry-go-contrib).

<!--renovate-debug:eyJjcmVhdGVkSW5WZXIiOiIzOC44MC4wIiwidXBkYXRlZEluVmVyIjoiMzguODAuMCIsInRhcmdldEJyYW5jaCI6Im1haW4iLCJsYWJlbHMiOlsiU2tpcCBDaGFuZ2Vsb2ciLCJkZXBlbmRlbmNpZXMiXX0=-->

Co-authored-by: renovate[bot] <29139614+renovate[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants