bytedance / sonic

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

opt: refactor streaming decoder to fully use buffer #550

Closed AsterDY closed 10 months ago

AsterDY commented 10 months ago

Optimization

name old alloc/op new alloc/op delta DecodeStream_Sonic/halt-16 265kB ± 0% 142kB ± 1% -46.38% (p=0.000 n=10+10) DecodeStream_Sonic/double-16 1.20MB ± 0% 0.28MB ± 0% -76.65% (p=0.000 n=10+10) DecodeStream_Sonic/4x-16 2.79MB ± 0% 0.56MB ± 0% -79.87% (p=0.000 n=10+10) DecodeStream_Sonic/single-16 1.32MB ± 0% 0.14MB ± 0% -89.36% (p=0.000 n=10+9) DecodeStream_Sonic/small-16 269kB ± 0% 1kB ± 0% -99.45% (p=0.000 n=10+10)

name old allocs/op new allocs/op delta DecodeStream_Sonic/small-16 21.0 ± 0% 20.0 ± 0% -4.76% (p=0.000 n=10+10) DecodeStream_Sonic/halt-16 12.0 ± 0% 9.0 ± 0% -25.00% (p=0.000 n=10+10) DecodeStream_Sonic/double-16 18.0 ± 0% 9.0 ± 0% -50.00% (p=0.000 n=10+10) DecodeStream_Sonic/4x-16 29.0 ± 0% 14.0 ± 0% -51.72% (p=0.000 n=10+10) DecodeStream_Sonic/single-16 11.0 ± 0% 5.0 ± 0% -54.55% (p=0.000 n=10+10)

codecov-commenter commented 10 months ago

Codecov Report

Merging #550 (eb1f9e4) into main (fd7e221) will increase coverage by 0.28%. Report is 3 commits behind head on main. The diff coverage is 97.18%.

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

@@            Coverage Diff             @@
##             main     #550      +/-   ##
==========================================
+ Coverage   78.30%   78.59%   +0.28%     
==========================================
  Files          69       69              
  Lines       10686    10692       +6     
==========================================
+ Hits         8368     8403      +35     
+ Misses       1955     1924      -31     
- Partials      363      365       +2     
Files Coverage Δ
internal/decoder/stream.go 92.17% <97.18%> (+28.87%) :arrow_up:

... and 1 file with indirect coverage changes

:mega: Codecov offers a browser extension for seamless coverage viewing on GitHub. Try it in Chrome or Firefox today!

AsterDY commented 10 months ago

fix #378