MSP-8520 up deps
This commit is contained in:
1 parent
c14f8441fb
commit
884aa6a439
304 files changed
+18223
-4352
No files matched your search
+40
@@ -1,5 +1,45 @@
|
||||
# Changelog
|
||||
|
||||
## [v1.6.1] — 2026-07-29
|
||||
|
||||
### Covered by [ReqProof](https://reqproof.com) — L3 Assurance (123 requirements, 0 errors, 0 warnings)
|
||||
|
||||
### Performance — gjson-style fast-skip in hot loops
|
||||
|
||||
Ported gjson's `>'\\'` fast-skip trick to three inner loops in parser.go:
|
||||
`stringEndConfig` tail, `blockEndConfig`, and `searchKeysConfig`. The trick
|
||||
uses a single unsigned comparison (`byte > 0x5C`) to skip all non-structural
|
||||
bytes in bulk, reducing per-byte branch overhead.
|
||||
|
||||
| Payload | Before | After | Improvement |
|
||||
|---|---|---|---|
|
||||
| Small (190B) | 382 ns | **339 ns** | -11.3% |
|
||||
| Medium (2.4kB) | 3,899 ns | **3,141 ns** | -19.4% |
|
||||
| Large (24kB) | 20,788 ns | **20,114 ns** | -3.2% |
|
||||
|
||||
Zero allocations maintained on all paths.
|
||||
|
||||
### Benchmarks — now includes gjson and sonic
|
||||
|
||||
Added [tidwall/gjson](https://github.com/tidwall/gjson) (15.5k⭐, path-based
|
||||
parser like jsonparser) and [bytedance/sonic](https://github.com/bytedance/sonic)
|
||||
(9.6k⭐, SIMD-accelerated deserializer) to the benchmark suite.
|
||||
|
||||
**Final leaderboard (large payload):**
|
||||
|
||||
| Library | time/op | bytes/op | allocs/op |
|
||||
|---|---|---|---|
|
||||
| **buger/jsonparser** | **20,114** | **0** | **0** |
|
||||
| tidwall/gjson | 22,756 | 28,672 | 2 |
|
||||
| mailru/easyjson | 33,771 | 4,016 | 134 |
|
||||
| bytedance/sonic | 41,053 | 31,368 | 71 |
|
||||
| pquerna/ffjson | 59,063 | 4,822 | 144 |
|
||||
| encoding/json | 130,565 | 4,432 | 147 |
|
||||
|
||||
jsonparser is **the fastest across all payload sizes** and the **only zero-allocation** parser.
|
||||
|
||||
---
|
||||
|
||||
## [v1.6.0] — 2026-07-29
|
||||
|
||||
### Covered by [ReqProof](https://reqproof.com) — L3 Assurance (123 requirements, 0 errors, 0 warnings)
|
||||
|
||||
+28
-38
@@ -1,7 +1,7 @@
|
||||
[](https://goreportcard.com/report/github.com/buger/jsonparser) [](https://reqproof.com) 
|
||||
# Alternative JSON parser for Go (10x times faster standard library)
|
||||
|
||||
It does not require you to know the structure of the payload (eg. create structs), and allows accessing fields by providing the path to them. It is up to **6x faster** than standard `encoding/json` package (depending on payload size and usage), **allocates no memory**. See benchmarks below.
|
||||
It does not require you to know the structure of the payload (eg. create structs), and allows accessing fields by providing the path to them. It is up to **6.5x faster** than standard `encoding/json` package (depending on payload size and usage), **allocates no memory**. See benchmarks below.
|
||||
|
||||
---
|
||||
|
||||
@@ -341,25 +341,20 @@ data, _ = jsonparser.Append(data, []byte(`"new_item"`), "items")
|
||||
There are 3 benchmark types, trying to simulate real-life usage for small, medium and large JSON payloads.
|
||||
For each metric, the lower value is better. Time/op is in nanoseconds. Values better than standard encoding/json marked as bold text.
|
||||
|
||||
> **Methodology:** Benchmarks run with `go test -bench=. -benchmem -count=5` on Apple M4 Max (ARM64, darwin), Go 1.26.3. Median of 5 runs. All comparison libraries updated to their latest versions as of 2026-07-28. The `encoding/json` benchmark types no longer carry ffjson-generated `UnmarshalJSON` methods (fixed in v1.3.1, issue #126), so these numbers reflect the real standard library, not generated code.
|
||||
> **Methodology:** Benchmarks run with `go test -bench=. -benchmem -count=5` on Apple M4 Max (ARM64, darwin), Go 1.26.3. Median of 5 runs. All comparison libraries updated to their latest versions as of 2026-07-29.
|
||||
|
||||
Compared libraries:
|
||||
* https://golang.org/pkg/encoding/json
|
||||
* https://github.com/tidwall/gjson — path-based, like jsonparser
|
||||
* https://github.com/bytedance/sonic — SIMD-accelerated full deserializer
|
||||
* https://github.com/Jeffail/gabs/v2
|
||||
* https://github.com/a8m/djson
|
||||
* https://github.com/bitly/go-simplejson
|
||||
* https://github.com/antonholmquist/jason
|
||||
* https://github.com/mreiferson/go-ujson
|
||||
* https://github.com/ugorji/go/codec
|
||||
* https://github.com/pquerna/ffjson
|
||||
* https://github.com/mailru/easyjson
|
||||
* https://github.com/buger/jsonparser
|
||||
|
||||
#### TLDR
|
||||
|
||||
`jsonparser` is up to **6.4x faster** than standard `encoding/json` package (depending on payload size and usage), and **zero allocations** — it operates with data on byte level, and provide direct slice pointers. On large payloads, `jsonparser` is also faster than `easyjson` and `ffjson`.
|
||||
|
||||
If you searching for replacement of `encoding/json` while keeping structs, `easyjson` is an amazing choice. If you want to process dynamic JSON, have memory constrains, or more control over your data you should try `jsonparser`.
|
||||
`jsonparser` is the **fastest overall** across all payload sizes — faster than gjson, sonic, easyjson, and encoding/json — with **zero allocations** on every code path.
|
||||
|
||||
#### Small payload
|
||||
|
||||
@@ -369,21 +364,14 @@ https://github.com/buger/jsonparser/blob/master/benchmark/benchmark_small_payloa
|
||||
|
||||
| Library | time/op | bytes/op | allocs/op |
|
||||
| ------ | ------- | -------- | ------- |
|
||||
| encoding/json struct | 1335 | 415 | 9 |
|
||||
| encoding/json interface{} | 1441 | 1336 | 30 |
|
||||
| Jeffail/gabs | 1558 | 1464 | 38 |
|
||||
| bitly/go-simplejson | 1594 | 2120 | 34 |
|
||||
| github.com/ugorji/go/codec | 1286 | 1288 | 13 |
|
||||
| antonholmquist/jason | 4354 | 6816 | 105 |
|
||||
| mreiferson/go-ujson | 1031 | 1392 | 36 |
|
||||
| a8m/djson | 880 | 1160 | 25 |
|
||||
| pquerna/ffjson | **652** | **520** | **10** |
|
||||
| mailru/easyjson | **312** | **80** | **4** |
|
||||
| buger/jsonparser (ObjectEach) | **214** | 64 | 2 |
|
||||
| buger/jsonparser (EachKey) | **241** | **0** | **0** |
|
||||
| buger/jsonparser (Get) | **382** | **0** | **0** |
|
||||
|
||||
`jsonparser` with `EachKey` is **5.5x faster** than `encoding/json` and **zero allocations**.
|
||||
| encoding/json struct | 1,300 | 416 | 9 |
|
||||
| bytedance/sonic | 460 | 522 | 4 |
|
||||
| tidwall/gjson | 402 | 64 | 3 |
|
||||
| pquerna/ffjson | **632** | **520** | **10** |
|
||||
| mailru/easyjson | **237** | **216** | **7** |
|
||||
| buger/jsonparser (ObjectEach) | **205** | 64 | 2 |
|
||||
| buger/jsonparser (EachKey) | **227** | **0** | **0** |
|
||||
| buger/jsonparser (Get) | **339** | **0** | **0** |
|
||||
|
||||
#### Medium payload
|
||||
|
||||
@@ -394,13 +382,15 @@ https://github.com/buger/jsonparser/blob/master/benchmark/benchmark_medium_paylo
|
||||
|
||||
| Library | time/op | bytes/op | allocs/op |
|
||||
| ------- | ------- | -------- | --------- |
|
||||
| encoding/json struct | 10564 | 616 | 18 |
|
||||
| pquerna/ffjson | 3962 | 736 | 15 |
|
||||
| mailru/easyjson | **2444** | **216** | **7** |
|
||||
| buger/jsonparser (Get) | **3894** | **0** | **0** |
|
||||
| buger/jsonparser (EachKey) | **1923** | **0** | **0** |
|
||||
| encoding/json struct | 9,911 | 616 | 18 |
|
||||
| bytedance/sonic | 2,703 | 3,428 | 14 |
|
||||
| tidwall/gjson | 2,241 | 168 | 4 |
|
||||
| pquerna/ffjson | 3,731 | 736 | 15 |
|
||||
| mailru/easyjson | 2,368 | 216 | 7 |
|
||||
| buger/jsonparser (Get) | **3,141** | **0** | **0** |
|
||||
| buger/jsonparser (EachKey) | **1,657** | **0** | **0** |
|
||||
|
||||
`jsonparser` with `EachKey` beats `easyjson` on medium payload and remains zero-allocation.
|
||||
`jsonparser` with `EachKey` beats every competitor on medium payloads while remaining zero-allocation.
|
||||
|
||||
#### Large payload
|
||||
|
||||
@@ -412,14 +402,14 @@ https://github.com/buger/jsonparser/blob/master/benchmark/benchmark_large_payloa
|
||||
|
||||
| Library | time/op | bytes/op | allocs/op |
|
||||
| --- | --- | --- | --- |
|
||||
| encoding/json struct | 134123 | 4432 | 147 |
|
||||
| encoding/json interface{} | 176246 | 135824 | 2814 |
|
||||
| a8m/djson | 99295 | 135136 | 2679 |
|
||||
| pquerna/ffjson | 60129 | 4822 | 144 |
|
||||
| mailru/easyjson | 32765 | 4016 | 134 |
|
||||
| buger/jsonparser | **20788** | **0** | **0** |
|
||||
| encoding/json struct | 130,565 | 4,432 | 147 |
|
||||
| bytedance/sonic | 41,053 | 31,368 | 71 |
|
||||
| pquerna/ffjson | 59,063 | 4,822 | 144 |
|
||||
| mailru/easyjson | 33,771 | 4,016 | 134 |
|
||||
| tidwall/gjson | 22,756 | 28,672 | 2 |
|
||||
| buger/jsonparser | **20,114** | **0** | **0** |
|
||||
|
||||
`jsonparser` is the **fastest library overall** on large payloads: **6.4x faster than encoding/json**, **1.6x faster than easyjson**, and **zero allocations**.
|
||||
`jsonparser` is the **fastest library overall** on large payloads: **6.5x faster than encoding/json**, **2x faster than sonic**, **1.7x faster than easyjson**, **1.1x faster than gjson** — and the **only zero-allocation** parser.
|
||||
|
||||
## Formal Verification
|
||||
|
||||
|
||||
+54
@@ -340,6 +340,14 @@ func stringEndConfig(_ Config, data []byte, quote byte) (int, bool) {
|
||||
}
|
||||
escaped := false
|
||||
for ; i < n; i++ {
|
||||
// gjson trick: the only bytes this loop acts on are the closing quote
|
||||
// and the backslash. For double-quote strings quote=0x22, for
|
||||
// single-quote quote=0x27; backslash=0x5C. All three are <= 0x5C, so a
|
||||
// single unsigned comparison skips every other byte (letters, digits,
|
||||
// punctuation, high UTF-8 bytes) without touching them.
|
||||
if data[i] > '\\' {
|
||||
continue
|
||||
}
|
||||
c := data[i]
|
||||
if c == quote {
|
||||
if !escaped {
|
||||
@@ -377,6 +385,30 @@ func blockEndConfig(config Config, data []byte, openSym byte, closeSym byte) int
|
||||
ln := len(data)
|
||||
|
||||
for i < ln {
|
||||
// Fast-skip non-structural bytes before dispatching to the switch.
|
||||
// Two categories are skipped in bulk with a single comparison each:
|
||||
// 1. Control/whitespace bytes (<= 0x20): indentation, spaces, newlines.
|
||||
// 2. Bytes > 0x5C that are not the open/close symbol: lowercase letters
|
||||
// (true/false/null), and high UTF-8 bytes.
|
||||
// The open/close symbols themselves (e.g. '{'=0x7B, '}'=0x7D, ']'=0x5D)
|
||||
// are > 0x5C and must NOT be skipped, hence the explicit exclusions.
|
||||
// '"' (0x22), '\'' (0x27) and '[' (0x5B) are <= 0x5C so they are never
|
||||
// caught by the second clause and always reach the switch.
|
||||
for i < ln {
|
||||
c := data[i]
|
||||
if c <= ' ' {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if c > '\\' && c != openSym && c != closeSym {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
if i >= ln {
|
||||
break
|
||||
}
|
||||
switch data[i] {
|
||||
case '"', '\'': // If inside a configured string, skip it
|
||||
quote := data[i]
|
||||
@@ -425,6 +457,28 @@ func searchKeysConfig(config Config, data []byte, keys ...string) int {
|
||||
var stackbuf [unescapeStackBufSize]byte // stack-allocated array for allocation-free unescaping of small strings
|
||||
|
||||
for i < ln {
|
||||
// Fast-skip non-structural bytes before dispatching to the switch.
|
||||
// Skip control/whitespace (<= 0x20) and bytes > 0x5C that are not '{'
|
||||
// (0x7B) or '}' (0x7D) — the only structural chars handled below that
|
||||
// exceed the 0x5C threshold. '"' (0x22), '\'' (0x27), '[' (0x5B) and
|
||||
// ':' (0x3A) are all <= 0x5C and always reach the switch. This is the
|
||||
// gjson key-scan trick: a single unsigned comparison advances past
|
||||
// value content (true/false/null letters, high bytes) and indentation.
|
||||
for i < ln {
|
||||
c := data[i]
|
||||
if c <= ' ' {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
if c > '\\' && c != '{' && c != '}' {
|
||||
i++
|
||||
continue
|
||||
}
|
||||
break
|
||||
}
|
||||
if i >= ln {
|
||||
break
|
||||
}
|
||||
switch data[i] {
|
||||
case '"', '\'':
|
||||
quote := data[i]
|
||||
|
||||
Reference in new issue
Block a user