romshark / jscan

High performance JSON iterator & validator for Go
BSD 3-Clause "New" or "Revised" License
89 stars 7 forks source link

feat: update go-faster/jx #2

Closed ernado closed 2 years ago

ernado commented 2 years ago
name                                     old time/op    new time/op    delta
Valid/tiny/gofaster-jx-32                  60.0ns ± 2%    44.1ns ± 2%   -26.57%  (p=0.008 n=5+5)
Valid/small/gofaster-jx-32                  815ns ± 7%     433ns ± 3%   -46.79%  (p=0.008 n=5+5)
Valid/large/gofaster-jx-32                 38.6ms ± 1%    28.3ms ± 2%   -26.56%  (p=0.008 n=5+5)
Valid/unwind_stack/gofaster-jx-32          1.29ms ± 2%    0.71ms ± 5%   -44.38%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/tiny-32              57.6ns ± 3%    51.7ns ± 2%   -10.25%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/small-32              895ns ± 5%     612ns ± 6%   -31.68%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/large-32             40.9ms ± 1%    35.6ms ± 1%   -13.00%  (p=0.008 n=5+5)
CalcStats/gofaster-jx_withpath/tiny-32     69.8ns ± 2%    56.2ns ± 2%   -19.49%  (p=0.008 n=5+5)
CalcStats/gofaster-jx_withpath/small-32    1.53µs ± 2%    0.65µs ± 2%   -57.34%  (p=0.008 n=5+5)
CalcStats/gofaster-jx_withpath/large-32     168ms ± 4%      35ms ± 2%   -79.10%  (p=0.008 n=5+5)

name                                     old alloc/op   new alloc/op   delta
Valid/tiny/gofaster-jx-32                   0.00B          0.00B           ~     (all equal)
Valid/small/gofaster-jx-32                  16.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
Valid/large/gofaster-jx-32                   137B ± 2%       99B ± 7%   -27.34%  (p=0.008 n=5+5)
Valid/unwind_stack/gofaster-jx-32           131kB ± 0%      66kB ± 0%   -49.90%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/tiny-32               0.00B          0.00B           ~     (all equal)
CalcStats/gofaster-jx/small-32              16.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/large-32               144B ± 4%      128B ± 3%   -11.11%  (p=0.008 n=5+5)
CalcStats/gofaster-jx_withpath/tiny-32      0.00B          0.00B           ~     (all equal)
CalcStats/gofaster-jx_withpath/small-32     80.0B ± 0%      0.0B       -100.00%  (p=0.008 n=5+5)
CalcStats/gofaster-jx_withpath/large-32    52.3MB ± 0%     0.0MB ± 2%  -100.00%  (p=0.008 n=5+5)

name                                     old allocs/op  new allocs/op  delta
Valid/tiny/gofaster-jx-32                    0.00           0.00           ~     (all equal)
Valid/small/gofaster-jx-32                   2.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
Valid/large/gofaster-jx-32                   0.00           0.00           ~     (all equal)
Valid/unwind_stack/gofaster-jx-32           2.05k ± 0%     1.03k ± 0%   -49.90%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/tiny-32                0.00           0.00           ~     (all equal)
CalcStats/gofaster-jx/small-32               2.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
CalcStats/gofaster-jx/large-32               0.00           0.00           ~     (all equal)
CalcStats/gofaster-jx_withpath/tiny-32       0.00           0.00           ~     (all equal)
CalcStats/gofaster-jx_withpath/small-32      13.0 ± 0%       0.0       -100.00%  (p=0.008 n=5+5)
CalcStats/gofaster-jx_withpath/large-32     1.54M ± 0%     0.00M       -100.00%  (p=0.008 n=5+5)

Please also update benchmarks in readme when you have time for it :heart:

romshark commented 2 years ago

I will update the README for relevant releases

ernado commented 2 years ago

I've also optimized withpath case, reducing allocations

ernado commented 2 years ago
goos: linux
goarch: amd64
pkg: github.com/romshark/jscan
cpu: AMD Ryzen 9 5950X 16-Core Processor            
BenchmarkCalcStats/jscan/tiny-32        97140116            64.14 ns/op        0 B/op          0 allocs/op
BenchmarkCalcStats/jscan/small-32       10741642           570.6 ns/op         0 B/op          0 allocs/op
BenchmarkCalcStats/jscan/large-32            199      29671587 ns/op          55 B/op          0 allocs/op
BenchmarkCalcStats/jsoniter/tiny-32     36711424           165.5 ns/op       160 B/op          2 allocs/op
BenchmarkCalcStats/jsoniter/small-32             4007560          1455 ns/op         224 B/op         12 allocs/op
BenchmarkCalcStats/jsoniter/large-32                  55     107943327 ns/op    33060242 B/op    1108611 allocs/op
BenchmarkCalcStats/gofaster-jx/tiny-32          115848550           50.53 ns/op        0 B/op          0 allocs/op
BenchmarkCalcStats/gofaster-jx/small-32         10810816           524.3 ns/op         0 B/op          0 allocs/op
BenchmarkCalcStats/gofaster-jx/large-32              228      26376531 ns/op          18 B/op          0 allocs/op
BenchmarkCalcStats/jscan_withpath/tiny-32       84674761            71.11 ns/op        0 B/op          0 allocs/op
BenchmarkCalcStats/jscan_withpath/small-32       7394097           782.8 ns/op         0 B/op          0 allocs/op
BenchmarkCalcStats/jscan_withpath/large-32           171      34641307 ns/op          65 B/op          0 allocs/op
BenchmarkCalcStats/jsoniter_withpath/tiny-32    29611117           198.8 ns/op       160 B/op          2 allocs/op
BenchmarkCalcStats/jsoniter_withpath/small-32            2720352          2186 ns/op         288 B/op         21 allocs/op
BenchmarkCalcStats/jsoniter_withpath/large-32                 37     155407604 ns/op    55805670 B/op    1757456 allocs/op
BenchmarkCalcStats/gofaster-jx_withpath/tiny-32         107339214           56.05 ns/op        0 B/op          0 allocs/op
BenchmarkCalcStats/gofaster-jx_withpath/small-32        10138044           614.3 ns/op         0 B/op          0 allocs/op
BenchmarkCalcStats/gofaster-jx_withpath/large-32             205      27768227 ns/op          20 B/op          0 allocs/op
BenchmarkGet/jscan-32                                   15059718           351.0 ns/op        16 B/op          2 allocs/op
BenchmarkGet/jsoniter-32                                 3344287          1853 ns/op         496 B/op         19 allocs/op
BenchmarkGet/tidwallgjson-32                            18632041           283.8 ns/op        16 B/op          2 allocs/op
BenchmarkValid/tiny/jscan-32                            135163837           44.15 ns/op        0 B/op          0 allocs/op
BenchmarkValid/tiny/jsoniter-32                         134281081           43.02 ns/op        0 B/op          0 allocs/op
BenchmarkValid/tiny/gofaster-jx-32                      124213034           48.40 ns/op        0 B/op          0 allocs/op
BenchmarkValid/tiny/encoding-json-32                    139128472           42.56 ns/op        0 B/op          0 allocs/op
BenchmarkValid/tiny/valyala-fastjson-32                 292225062           20.90 ns/op        0 B/op          0 allocs/op
BenchmarkValid/small/jscan-32                           11595009           502.9 ns/op         0 B/op          0 allocs/op
BenchmarkValid/small/jsoniter-32                         5421649           982.8 ns/op        56 B/op          7 allocs/op
BenchmarkValid/small/gofaster-jx-32                     12536254           419.5 ns/op         0 B/op          0 allocs/op
BenchmarkValid/small/encoding-json-32                    6389982           919.0 ns/op         0 B/op          0 allocs/op
BenchmarkValid/small/valyala-fastjson-32                18200816           307.3 ns/op         0 B/op          0 allocs/op
BenchmarkValid/large/jscan-32                                213      28096382 ns/op          19 B/op          0 allocs/op
BenchmarkValid/large/jsoniter-32                              62      87904545 ns/op    13794985 B/op     644454 allocs/op
BenchmarkValid/large/gofaster-jx-32                          298      19915917 ns/op          13 B/op          0 allocs/op
BenchmarkValid/large/encoding-json-32                         79      73060592 ns/op          54 B/op          0 allocs/op
BenchmarkValid/large/valyala-fastjson-32                     262      22469637 ns/op           0 B/op          0 allocs/op
BenchmarkValid/unwind_stack/jscan-32                      751837          8223 ns/op           0 B/op          0 allocs/op
BenchmarkValid/unwind_stack/jsoniter-32                    44550        132099 ns/op       33200 B/op       1033 allocs/op
BenchmarkValid/unwind_stack/gofaster-jx-32                  7948        734624 ns/op       65739 B/op       1026 allocs/op
BenchmarkValid/unwind_stack/encoding-json-32             1011835          5898 ns/op          24 B/op          1 allocs/op
BenchmarkValid/unwind_stack/valyala-fastjson-32              558      10087900 ns/op    52510084 B/op       4136 allocs/op
PASS
ok      github.com/romshark/jscan   318.404s