bytedance / sonic-cpp

A fast JSON serializing & deserializing library, accelerated by SIMD.
Apache License 2.0
835 stars 101 forks source link

feat: support parse and parselazy with sax handler #5

Closed liuq19 closed 1 year ago

liuq19 commented 1 year ago

Main Changes:

  1. refactor the parser as sax-style
  2. parseondemand also use sax-style, and optimize lots

ParseOnDemand Performance

Comparing /tmp/tmpzu6hwo3r.master.json to /tmp/tmpu_mulh5j.target.json
Benchmark                                            Time             CPU      Time Old      Time New       CPU Old       CPU New
---------------------------------------------------------------------------------------------------------------------------------
twitter/SonicOnDemand_Normal                      -0.2318         -0.2318         26863         20637         26864         20636
citm_catalog/SonicOnDemand_Fronter                -0.8479         -0.8479         71691         10907         71690         10907
twitter/SonicOnDemand_NotFound                    -0.2406         -0.2406         26836         20379         26835         20379
tools2/draw-png.py /tmp/tmpu_mulh5j.target.json

Parse Performance

Comparing /tmp/tmpxxfefh8b.master.json to /tmp/tmpmxor0ng0.target.json
Benchmark                                        Time             CPU      Time Old      Time New       CPU Old       CPU New
-----------------------------------------------------------------------------------------------------------------------------
book/Decode_SonicDyn                          +0.1570         +0.1570           688           796           688           796
twitter/Decode_SonicDyn                       -0.0024         -0.0024        137448        137114        137448        137114
poet/Decode_SonicDyn                          +0.0233         +0.0234        944678        966678        944547        966665
canada/Decode_SonicDyn                        +0.0054         +0.0054       2588317       2602310       2588272       2602258
github_events/Decode_SonicDyn                 +0.0310         +0.0311         31211         32178         31207         32178
lottie/Decode_SonicDyn                        -0.0081         -0.0081        680423        674913        680395        674906
otfcc/Decode_SonicDyn                         -0.0404         -0.0404     184449037     176991304     184448816     176991763
citm_catalog/Decode_SonicDyn                  -0.0160         -0.0160        880897        866765        880898        866769
twitterescaped/Decode_SonicDyn                +0.0187         +0.0187        380641        387773        380642        387768
fgo/Decode_SonicDyn                           -0.0583         -0.0585      67977428      64011544      67977512      63998854
gsoc-2018/Decode_SonicDyn                     +0.0103         +0.0104        801498        809738        801396        809740
xiegx94 commented 1 year ago

Suqash all commits as one.