bytedance / sonic-cpp

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

arm: Implement SVE2 str2int #95

Open supermartian opened 3 weeks ago

supermartian commented 3 weeks ago

This patch implements a SVE2 version of str2int which improves number decoding on ARM SVE2 CPUs.

The algorithm utilizes SVMATCH to count valid digits in the string, and SDOT for calculating the value. With this change the naive byte-by-byte method for ARM is substituted. Note that these instructions are SVE2 only.

Enable it by compiling with adding cmake option "-DENABLE_SVE2_128=ON".

Numbers were tested on NVIDIA Grace.

| Benchmark                      | Original     | SVE2       | Improvement |
|--------------------------------|--------------|------------|-------------|
| testdata/gsoc-2018.json        | 3406307500   | 3407847500 | 0.05%       |
| testdata/twitter.json          | 2040162500   | 2039502500 | -0.03%      |
| testdata/fgo.json              | 992470750    | 988730000  | -0.38%      |
| testdata/citm_catalog.json     | 2209855000   | 2205997500 | -0.17%      |
| testdata/twitterescaped.json   | 1767812500   | 1814302500 | 2.63%       |
| testdata/github_events.json    | 2142690000   | 2147452500 | 0.22%       |
| testdata/lottie.json           | 625985250    | 602068500  | -3.82%      |
| testdata/poet.json             | 2867745000   | 2880562500 | 0.45%       |
| testdata/otfcc.json            | 685481500    | 683760750  | -0.25%      |
| testdata/book.json             | 687309000    | 674716000  | -1.83%      |
| testdata/canada.json           | 775475000    | 1051945000 | 35.65%      |

This PR is contributed by NVIDIA

xiegx94 commented 19 hours ago

@supermartian format codes with clang-format