Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Optimized SIMD routines for escaping JSON strings

NotificationsYou must be signed in to change notification settings

napi-rs/json-escape-simd

Repository files navigation

Crates.io Versiondocs.rsCodSpeed Badge

Optimized SIMD routines for escaping JSON strings. The implementation is fromsonic-rs, we only take the string escaping part to avoid the abstraction overhead.

Benchmarks

Numbers below come fromcargo bench runs on GitHub Actions hardware. Criterion reports are summarized to make it easier to spot relative performance. "vs fastest" shows how much slower each implementation is compared to the fastest entry in the table (1.00× means fastest).

GitHub Actions x86_64 (ubuntu-latest)

AVX2 enabled.

Short string payload (~89M iterations)

ImplementationMedian timevs fastest
escape simd56.23 ns1.00×
escape generic111.58 ns1.98×
serde_json111.65 ns1.99×
json-escape140.01 ns2.49×
escape v_jsonescape151.98 ns2.70×
escape sonic202.21 ns3.60×

RxJS payload (~10k iterations)

ImplementationMedian timevs fastest
escape simd246.84 µs1.00×
escape sonic261.87 µs1.06×
escape v_jsonescape531.77 µs2.15×
json-escape561.93 µs2.28×
escape generic664.00 µs2.69×
serde_json649.19 µs2.63×

Fixtures payload (~300 iterations)

ImplementationMedian timevs fastest
escape simd9.1461 ms1.00×
escape sonic9.3410 ms1.02×
json-escape19.077 ms2.09×
escape v_jsonescape20.015 ms2.19×
serde_json21.240 ms2.32×
escape generic22.512 ms2.46×

GitHub Actions aarch64 (ubuntu-24.04-arm)

Neon enabled.

Short string payload (~76M iterations)

ImplementationMedian timevs fastest
escape simd65.42 ns1.00×
escape generic108.28 ns1.66×
serde_json110.73 ns1.69×
json-escape150.64 ns2.30×
escape v_jsonescape183.41 ns2.80×
escape sonic212.87 ns3.25×

RxJS payload (~10k iterations)

ImplementationMedian timevs fastest
escape simd283.40 µs1.00×
escape sonic305.34 µs1.08×
json-escape468.04 µs1.65×
escape generic548.50 µs1.94×
serde_json567.23 µs2.00×
escape v_jsonescape758.18 µs2.68×

Fixtures payload (~300 iterations)

ImplementationMedian timevs fastest
escape simd10.46 ms1.00×
escape sonic11.18 ms1.07×
json-escape15.45 ms1.48×
escape generic17.75 ms1.70×
serde_json18.01 ms1.72×
escape v_jsonescape24.93 ms2.38×

GitHub Actions macOS (macos-latest)

Apple M1 chip

Short string payload (~45M iterations)

ImplementationMedian timevs fastest
escape simd113.16 ns1.00×
serde_json128.52 ns1.14×
escape generic136.06 ns1.20×
json-escape173.16 ns1.53×
escape v_jsonescape198.80 ns1.76×
escape sonic226.21 ns2.00×

RxJS payload (~10k iterations)

ImplementationMedian timevs fastest
escape sonic379.94 µs1.00×
escape simd395.41 µs1.04×
json-escape618.74 µs1.63×
escape generic690.86 µs1.82×
serde_json720.05 µs1.89×
escape v_jsonescape839.86 µs2.21×

AFFiNE sources payload (~300 iterations)

ImplementationMedian timevs fastest
escape simd12.60 ms1.00×
escape sonic14.04 ms1.11×
json-escape21.54 ms1.71×
serde_json23.33 ms1.85×
escape generic24.55 ms1.95×
escape v_jsonescape26.82 ms2.13×

Apple M3 Max

Short string benchmark

ImplementationMedian timevs fastest
escape simd90.58 ns1.00×
serde_json139.23 ns1.54×
escape generic146.15 ns1.61×
json-escape173.60 ns1.92×
escape v_jsonescape198.60 ns2.19×
escape sonic199.27 ns2.20×

RxJS payload (~10k iterations)

ImplementationMedian timevs fastest
escape simd196.07 µs1.00×
escape sonic196.32 µs1.00×
json-escape446.94 µs2.28×
escape generic488.37 µs2.49×
serde_json553.08 µs2.82×
escape v_jsonescape618.31 µs3.15×

AFFiNE sources payload (~300 iterations)

ImplementationMedian timevs fastest
escape simd10.36 ms1.00×
escape sonic10.57 ms1.02×
escape generic17.61 ms1.70×
json-escape18.01 ms1.74×
serde_json19.00 ms1.83×
escape v_jsonescape21.38 ms2.06×

About

Optimized SIMD routines for escaping JSON strings

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published

Contributors3

  •  
  •  
  •  

[8]ページ先頭

©2009-2025 Movatter.jp