simd-json icon indicating copy to clipboard operation
simd-json copied to clipboard

Improve alignment

Open Licenser opened this issue 1 year ago • 15 comments

Improve alignment to avoid unaligned memory reads

Licenser avatar Aug 31 '24 19:08 Licenser

Benchmark for e9fee9f

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 90.9±1.42µs 90.9±3.38µs 0.00%
canada/simd_json::to_tape_with_buffers 3.8±0.13ms 3.7±0.14ms -2.63%
citm_catalog/simd_json::to_tape_with_buffers 1132.5±79.99µs 1117.9±71.08µs -1.29%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.6±0.20µs 3.8±0.21µs +5.56%
github_events/simd_json::to_tape_with_buffers 40.1±0.89µs 39.9±0.92µs -0.50%
log/simd_json::to_tape_with_buffers 1525.4±67.75ns 1551.1±79.38ns +1.68%
twitter/simd_json::to_tape_with_buffers 435.5±25.71µs 434.7±23.79µs -0.18%

github-actions[bot] avatar Aug 31 '24 19:08 github-actions[bot]

Benchmark for dabe1af

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 92.0±2.09µs 92.0±2.05µs 0.00%
canada/simd_json::to_tape_with_buffers 3.8±0.18ms 3.7±0.16ms -2.63%
citm_catalog/simd_json::to_tape_with_buffers 1147.1±83.80µs 1128.3±87.86µs -1.64%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.23µs 3.9±0.26µs +5.41%
github_events/simd_json::to_tape_with_buffers 40.5±1.11µs 40.9±1.12µs +0.99%
log/simd_json::to_tape_with_buffers 1588.5±89.25ns 1584.0±107.70ns -0.28%
twitter/simd_json::to_tape_with_buffers 450.6±27.37µs 444.6±23.26µs -1.33%

github-actions[bot] avatar Aug 31 '24 20:08 github-actions[bot]

Benchmark for 00d086f

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 92.5±1.52µs 92.1±1.62µs -0.43%
canada/simd_json::to_tape_with_buffers 3.7±0.12ms 3.7±0.16ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1138.2±78.97µs 1123.4±77.18µs -1.30%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.8±0.24µs 4.0±0.25µs +5.26%
github_events/simd_json::to_tape_with_buffers 40.9±1.06µs 40.7±1.10µs -0.49%
log/simd_json::to_tape_with_buffers 1562.7±86.43ns 1650.9±117.36ns +5.64%
twitter/simd_json::to_tape_with_buffers 440.6±30.38µs 435.5±26.54µs -1.16%

github-actions[bot] avatar Sep 11 '24 07:09 github-actions[bot]

Benchmark for a10a17e

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 90.7±1.52µs 90.8±2.00µs +0.11%
canada/simd_json::to_tape_with_buffers 3.8±0.16ms 3.6±0.17ms -5.26%
citm_catalog/simd_json::to_tape_with_buffers 1129.8±77.90µs 1121.5±77.25µs -0.73%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.24µs 3.8±0.19µs +2.70%
github_events/simd_json::to_tape_with_buffers 40.4±2.19µs 40.1±0.93µs -0.74%
log/simd_json::to_tape_with_buffers 1577.2±98.29ns 1577.8±89.79ns +0.04%
twitter/simd_json::to_tape_with_buffers 447.7±27.47µs 435.3±23.62µs -2.77%

github-actions[bot] avatar Sep 13 '24 13:09 github-actions[bot]

Codecov Report

Attention: Patch coverage is 97.72727% with 1 line in your changes missing coverage. Please review.

Project coverage is 71.53%. Comparing base (8a9169b) to head (3aad36b). Report is 174 commits behind head on main.

Files with missing lines Patch % Lines
src/lib.rs 96.77% 1 Missing :warning:

:exclamation: There is a different number of reports uploaded between BASE (8a9169b) and HEAD (3aad36b). Click for more details.

HEAD has 7 uploads less than BASE
Flag BASE (8a9169b) HEAD (3aad36b)
128bit 2 0
3 0
beef 2 0
Additional details and impacted files
@@             Coverage Diff             @@
##             main     #387       +/-   ##
===========================================
- Coverage   81.83%   71.53%   -10.30%     
===========================================
  Files          32       51       +19     
  Lines        9992    12340     +2348     
===========================================
+ Hits         8177     8828      +651     
- Misses       1815     3512     +1697     
Flag Coverage Δ
?
128bit ?
beef ?
unittests 71.53% <97.72%> (?)

Flags with carried forward coverage won't be shown. Click here to find out more.

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.

codecov[bot] avatar Oct 08 '24 15:10 codecov[bot]

Benchmark for c0f9298

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 93.1±1.54µs 92.3±1.35µs -0.86%
canada/simd_json::to_tape_with_buffers 3.9±0.14ms 3.7±0.14ms -5.13%
citm_catalog/simd_json::to_tape_with_buffers 1145.9±83.24µs 1124.9±92.25µs -1.83%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.8±0.20µs 4.0±0.22µs +5.26%
github_events/simd_json::to_tape_with_buffers 41.0±0.96µs 41.5±0.98µs +1.22%
log/simd_json::to_tape_with_buffers 1597.1±94.00ns 1585.5±99.97ns -0.73%
twitter/simd_json::to_tape_with_buffers 451.6±29.53µs 444.1±25.44µs -1.66%

github-actions[bot] avatar Oct 08 '24 15:10 github-actions[bot]

Benchmark for 97e1857

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 94.5±3.85µs 93.9±3.39µs -0.63%
canada/simd_json::to_tape_with_buffers 3.8±0.18ms 3.9±0.13ms +2.63%
citm_catalog/simd_json::to_tape_with_buffers 1161.0±85.07µs 1147.2±84.52µs -1.19%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.9±0.23µs 4.1±0.26µs +5.13%
github_events/simd_json::to_tape_with_buffers 41.6±1.00µs 41.5±1.17µs -0.24%
log/simd_json::to_tape_with_buffers 1630.9±108.37ns 1708.4±180.21ns +4.75%
twitter/simd_json::to_tape_with_buffers 451.3±29.04µs 450.2±28.02µs -0.24%

github-actions[bot] avatar Oct 08 '24 19:10 github-actions[bot]

Benchmark for 9e4b729

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 91.2±2.14µs 91.4±1.40µs +0.22%
canada/simd_json::to_tape_with_buffers 3.3±0.15ms 3.3±0.09ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1048.6±69.53µs 1039.4±61.39µs -0.88%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.23µs 4.0±0.26µs +8.11%
github_events/simd_json::to_tape_with_buffers 40.5±1.07µs 42.0±1.61µs +3.70%
log/simd_json::to_tape_with_buffers 1551.9±90.02ns 1576.6±97.04ns +1.59%
twitter/simd_json::to_tape_with_buffers 427.3±39.71µs 419.1±25.00µs -1.92%

github-actions[bot] avatar Mar 20 '25 13:03 github-actions[bot]

Benchmark for bb4a1be

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 95.1±2.02µs 93.0±1.66µs -2.21%
canada/simd_json::to_tape_with_buffers 3.3±0.16ms 3.4±0.17ms +3.03%
citm_catalog/simd_json::to_tape_with_buffers 1077.1±75.96µs 1067.0±72.56µs -0.94%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.9±0.23µs 4.2±0.28µs +7.69%
github_events/simd_json::to_tape_with_buffers 41.7±1.05µs 42.2±1.32µs +1.20%
log/simd_json::to_tape_with_buffers 1622.2±112.87ns 1618.5±117.66ns -0.23%
twitter/simd_json::to_tape_with_buffers 434.0±28.33µs 427.0±28.81µs -1.61%

github-actions[bot] avatar Mar 20 '25 13:03 github-actions[bot]

Benchmark for f0d7e5c

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 90.7±2.00µs 92.8±1.25µs +2.32%
canada/simd_json::to_tape_with_buffers 3.3±0.17ms 3.3±0.15ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1060.8±76.54µs 1048.9±68.67µs -1.12%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.7±0.19µs 4.0±0.25µs +8.11%
github_events/simd_json::to_tape_with_buffers 40.1±0.68µs 41.1±1.03µs +2.49%
log/simd_json::to_tape_with_buffers 1572.5±99.80ns 1553.2±94.26ns -1.23%
twitter/simd_json::to_tape_with_buffers 422.6±28.94µs 418.1±24.79µs -1.06%

github-actions[bot] avatar Mar 20 '25 13:03 github-actions[bot]

Benchmark for 2db3ddd

Click to view benchmark
Test Base PR %
apache_builds/simd_json::to_tape_with_buffers 92.9±2.67µs 92.2±2.31µs -0.75%
canada/simd_json::to_tape_with_buffers 3.3±0.15ms 3.3±0.14ms 0.00%
citm_catalog/simd_json::to_tape_with_buffers 1072.0±81.37µs 1059.0±71.49µs -1.21%
event_stacktrace_10kb/simd_json::to_tape_with_buffers 3.9±0.25µs 4.0±0.25µs +2.56%
github_events/simd_json::to_tape_with_buffers 41.4±1.39µs 41.5±1.35µs +0.24%
log/simd_json::to_tape_with_buffers 1576.0±96.37ns 1631.9±130.55ns +3.55%
twitter/simd_json::to_tape_with_buffers 429.0±29.77µs 427.3±31.21µs -0.40%

github-actions[bot] avatar Aug 01 '25 14:08 github-actions[bot]

@Licenser this seems worth it.

umbrageodotus avatar Oct 20 '25 15:10 umbrageodotus

While in theory I agree, the benchmarks kind of point to a different result while there are some that improve there are also some that quite noticeably degrade. The GitHub benchmarks are not a surefire way to determine exact numbers but if you look over all the runs the trend is showing a over all degradation not a improvement :( which is sad because it should be faster but CPUs and compilers are sneaky.

Licenser avatar Oct 20 '25 17:10 Licenser

While in theory I agree, the benchmarks kind of point to a different result while there are some that improve there are also some that quite noticeably degrade. The GitHub benchmarks are not a surefire way to determine exact numbers but if you look over all the runs the trend is showing a over all degradation not a improvement :( which is sad because it should be faster but CPUs and compilers are sneaky.

There's only one big degradation which is log/simd_json::to_tape_with_buffers - the rest seems like measuring errors. I can help figure out what the compiler is doing...

umbrageodotus avatar Oct 20 '25 19:10 umbrageodotus

If you look at all the benchmarks, both event_stacktrace_10kb/simd_json::to_tape_with_buffers and log/simd_json::to_tape_with_buffers both show quite consistent degradation but if this kind of thing excites you (I know it excites me :D those problems are awesome I sadly didn't have the time to dig lately) you are welcome to take it over. I suspect there is some fun low level fiddling involved here :)

Licenser avatar Oct 20 '25 19:10 Licenser