Skip to content

feat(arm64): add a 256-bit SVE2 backend - #157

Open
Weihong-ye wants to merge 3 commits into
bytedance:masterfrom
Weihong-ye:master
Open

Weihong-ye wants to merge 3 commits into
bytedance:masterfrom
Weihong-ye:master

Conversation

@Weihong-ye

Copy link
Copy Markdown

Summary

This PR adds an opt-in, fixed-width 256-bit SVE2 backend for AArch64, as proposed in #143. PR #117 was based on an earlier version of the same implementation. This version further optimizes both JSON serialization and deserialization, including string escaping, whitespace scanning, and integer conversion.

The encoder uses SVE2 for string escaping and integer formatting. The decoder uses it for string scanning and unescaping, whitespace scanning, and integer parsing. On-demand container skipping continues to use the existing NEON implementation.

How to enable it

The backend uses static dispatch and requires a runtime SVE vector length of 256 bits.

  • CMake: -DENABLE_SVE2_256=ON
  • Bazel: --//:sonic_arch=sve2 --//:sve_vector_bits=256

With Bazel, sonic_arch=sve2 defaults to 128 bits, and sonic_arch=arm selects NEON.

Performance

We compared NEON, SVE2-128, and SVE2-256 on the same Kunpeng 950 core using Clang 16.0.6 and all 11 JSON files in testdata. The table shows the average CPU-time reduction relative to NEON for each build. Positive values mean less CPU time.

Backend CMake -O3 serialize CMake -O3 deserialize Bazel -O3 serialize Bazel -O3 deserialize
NEON baseline baseline baseline baseline
SVE2-128 +0.27% −1.26% −0.45% −0.69%
SVE2-256 +5.54% +25.53% +5.11% +25.87%

We measured full DOM serialization and deserialization (Encode_SonicDyn and Decode_SonicDyn). For each input and backend, we took the median of six CPU-time measurements, then averaged the per-input percentage changes with equal weight.

SVE2-256 reduced deserialization time on 10 of 11 inputs in both builds. The small book.json input was slower than NEON for both operations. Bazel's default -c opt build (-O2) showed a similar overall result for SVE2-256: 4.71% less CPU time for serialization and 26.23% less for deserialization.

Testing

  • All 304 unit tests passed on Kunpeng 950 with the SVE2-256 backend in both the CMake build (with AddressSanitizer enabled) and the Bazel build.
  • Verified that Bazel selects NEON for sonic_arch=arm, SVE2-128 for sonic_arch=sve2 by default, and SVE2-256 for sonic_arch=sve2 with sve_vector_bits=256.

The SVE2-256 optimizations in this PR were contributed by Huawei.

@Weihong-ye

Copy link
Copy Markdown
Author

Hi @liuq19, @yangzhg, and @hsqStephenZhang! Could someone with write access approve the pending CI runs? I’d also appreciate a review from any maintainer who has a chance to take a look. Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant