Code Monkey home page Code Monkey logo

rust_serialization_benchmark's Introduction

Rust serialization benchmark

The goal of these benchmarks is to provide thorough and complete benchmarks for various rust serialization frameworks.

These benchmarks are a work in progress

These benchmarks are still being developed and pull requests to improve benchmarks are welcome.

You can use this horrible tiny webpage to turn a benchmark log into nicely-formatted markdown tables.

Format

All tests benchmark the following properties (time or size):

  • Serialize: serialize data into a buffer
  • Deserialize: deserializes a buffer into a normal rust object
  • Size: the size of the buffer when serialized
  • Zlib: the size of the buffer after zlib compression

Zero-copy deserialization libraries have an additional set of benchmarks:

  • Access: accesses a buffer as structured data
  • Read: runs through a buffer and reads fields out of it
  • Update: updates a buffer as structured data

Some benchmark results may be italicized and followed by an asterisk. Mouse over these for more details on what situation was benchmarked. Other footnotes are located at the bottom.

Last updated: 11/29/2021

log

This data set is composed of HTTP request logs that are small and contain many strings.

Raw Data

For operations, time per iteration; for size, bytes. Lower is better.

Serialize / deserialize speed and size

Format / Lib Serialize Deserialize Size Zlib Zstd
abomonation 239.45 us 2.9763 ms* 1705800 507150 405443
bincode 497.62 us 3.7935 ms 1045784 374305 312658
borsh 512.29 us 3.7558 ms 885780 363280 286948
bson 3.2398 ms 11.466 ms 1924682 537661 377489
capnp 1.4190 ms 1443216 509618 429784
cbor 1.8215 ms 7.8008 ms 1407835 407372 325016
flatbuffers 2.4512 ms 1276368 469962 389885
nachricht 4.2831 ms 6.5536 ms 926221 365209 304177
postcard 645.02 us 4.3221 ms 765778 312739 265462
prost 4.4750 ms* 798.69 us* 8.8317 ms 764951 269811 228807
rkyv 276.82 us 2.7300 ms* 3.4442 ms* 1011488 392809 332689
rmp 1.8461 ms 4.7317 ms 784997 326654 278933
ron 23.034 ms 16.148 ms 1607459 452648 351604
serde_json 4.2477 ms 9.1914 ms 1827461 474358 364177
simd-json 4.0963 ms 8.9160 ms 1827461 474358 364177
speedy 244.56 us 3.1769 ms 885780 363280 286948
alkahest 232.09 us 1045784 454748 389910

Zero-copy deserialization speed

Format / Lib Access Read Update
abomonation 50.281 us* 75.922 us*
capnp 170.11 ns* 581.31 us*
flatbuffers 2.8251 ns* 2.3512 ms* 155.53 us* 2.4411 ms*
rkyv 1.2624 ns* 658.19 us* 15.972 us* 674.73 us* 55.444 us
alkahest 1.9109 ns* 70.966 us*

Comparison

Relative to best. Higher is better.

Serialize / deserialize speed and size

Format / Lib Serialize Deserialize Size Zlib Zstd
abomonation 96.93% 91.72%* 44.84% 53.20% 56.43%
bincode 46.64% 71.97% 73.15% 72.08% 73.18%
borsh 45.30% 72.69% 86.36% 74.27% 79.74%
bson 7.16% 23.81% 39.74% 50.18% 60.61%
capnp 16.36% 53.00% 52.94% 53.24%
cbor 12.74% 35.00% 54.34% 66.23% 70.40%
flatbuffers 9.47% 59.93% 57.41% 58.69%
nachricht 5.42% 41.66% 82.59% 73.88% 75.22%
postcard 35.98% 63.16% 99.89% 86.27% 86.19%
prost 5.19%* 29.06%* 30.91% 100.00% 100.00% 100.00%
rkyv 83.84% 100.00%* 79.26%* 75.63% 68.69% 68.78%
rmp 12.57% 57.70% 97.45% 82.60% 82.03%
ron 1.01% 16.91% 47.59% 59.61% 65.08%
serde_json 5.46% 29.70% 41.86% 56.88% 62.83%
simd-json 5.67% 30.62% 41.86% 56.88% 62.83%
speedy 94.90% 85.93% 86.36% 74.27% 79.74%
alkahest 100.00% 73.15% 59.33% 58.68%

Zero-copy deserialization speed

Format / Lib Access Read Update
abomonation 0.00%* 21.04%*
capnp 0.74%* 2.75%*
flatbuffers 44.69%* 0.00%* 10.27%* 0.65%*
rkyv 100.00%* 0.00%* 100.00%* 2.37%* 100.00%
alkahest 66.06%* 22.51%*

mesh

This data set is a single mesh. The mesh contains an array of triangles, each of which has three vertices and a normal vector.

Raw Data

For operations, time per iteration; for size, bytes. Lower is better.

Serialize / deserialize speed and size

Format / Lib Serialize Deserialize Size Zlib Zstd
abomonation 357.48 us 1.6575 ms* 6000024 5380836 5345893
bincode 4.6646 ms 5.9235 ms 6000008 5380823 5345885
borsh 6.9330 ms 8.6247 ms 6000004 5380818 5345888
bson 59.888 ms 123.20 ms 23013911 9211138 7501230
capnp 21.611 ms 14000088 6729881 6051413
cbor 40.682 ms 66.170 ms 13122324 7527423 6761276
flatbuffers 2.1025 ms 6000024 5380800 5345925
nachricht 62.391 ms 36.754 ms 10125030 7160144 6777986
postcard 5.8788 ms 10.183 ms 6000003 5380817 5345893
prost 21.310 ms* 15.139 ms* 20.325 ms 8750000 6683814 6421721
rkyv 718.53 us 1.8408 ms* 1.8406 ms* 6000008 5380822 5345887
rmp 16.159 ms 20.422 ms 8125006 6496879 6391025
ron 211.17 ms 258.24 ms 22192885 9009575 8147524
serde_json 95.967 ms 88.608 ms 26192883 9612105 8595089
simd-json 99.210 ms 120.84 ms 39152823 16587283 14555990
speedy 651.91 us 2.2203 ms 6000004 5380818 5345888
alkahest 614.17 us 6000008 5380823 5345885

Zero-copy deserialization speed

Format / Lib Access Read Update
abomonation 2.3751 ns* 175.23 us*
capnp 252.78 ns* 7.8701 ms*
flatbuffers 2.5732 ns* 42.283 ns* 139.52 us* 139.67 us*
rkyv 1.2620 ns* 14.443 ns* 34.877 us* 35.092 us* 531.48 us
alkahest 1.8985 ns* 69.758 us*

Comparison

Relative to best. Higher is better.

Serialize / deserialize speed and size

Format / Lib Serialize Deserialize Size Zlib Zstd
abomonation 100.00% 100.00%* 100.00% 100.00% 100.00%
bincode 7.66% 27.98% 100.00% 100.00% 100.00%
borsh 5.16% 19.22% 100.00% 100.00% 100.00%
bson 0.60% 1.35% 26.07% 58.42% 71.27%
capnp 1.65% 42.86% 79.95% 88.34%
cbor 0.88% 2.50% 45.72% 71.48% 79.07%
flatbuffers 17.00% 100.00% 100.00% 100.00%
nachricht 0.57% 4.51% 59.26% 75.15% 78.87%
postcard 6.08% 16.28% 100.00% 100.00% 100.00%
prost 1.68%* 2.36%* 8.15% 68.57% 80.50% 83.25%
rkyv 49.75% 90.04%* 90.05%* 100.00% 100.00% 100.00%
rmp 2.21% 8.12% 73.85% 82.82% 83.65%
ron 0.17% 0.64% 27.04% 59.72% 65.61%
serde_json 0.37% 1.87% 22.91% 55.98% 62.20%
simd-json 0.36% 1.37% 15.32% 32.44% 36.73%
speedy 54.84% 74.65% 100.00% 100.00% 100.00%
alkahest 58.21% 100.00% 100.00% 100.00%

Zero-copy deserialization speed

Format / Lib Access Read Update
abomonation 53.13%* 19.90%*
capnp 0.50%* 0.44%*
flatbuffers 49.04%* 2.98%* 25.00%* 24.97%*
rkyv 100.00%* 8.74%* 100.00%* 99.39%* 100.00%
alkahest 66.47%* 50.00%*

minecraft_savedata

This data set is composed of Minecraft player saves that contain highly structured data.

Raw Data

For operations, time per iteration; for size, bytes. Lower is better.

Serialize / deserialize speed and size

Format / Lib Serialize Deserialize Size Zlib Zstd
abomonation 330.28 us 2.3437 ms* 1290592 391277 329474
bincode 647.92 us 3.0044 ms 569975 240897 232904
borsh 670.69 us 2.8793 ms 446595 234395 210623
bson 6.0056 ms 12.582 ms 1619653 506953 328780
capnp 840.18 us 803896 336655 281557
cbor 1.8329 ms 7.7217 ms 1109821 347812 275365
flatbuffers 32.055 ms 844168 346957 295321
nachricht 5.3026 ms 6.0314 ms 535875 282125 250252
postcard 696.65 us 3.5101 ms 356311 213270 199012
prost 4.5820 ms* 1.6590 ms* 7.8249 ms 596811 306728 270153
rkyv 443.69 us 2.1900 ms* 2.7479 ms* 596952 254571 220523
rmp 1.6200 ms 4.0374 ms 418025 244869 226158
ron 10.805 ms 16.400 ms 1465223 439761 345579
serde_json 4.3212 ms 9.6048 ms 1623191 472275 362019
simd-json 4.4106 ms 8.1604 ms 1663769 496401 386208
speedy 412.83 us 2.4766 ms 449595 235136 210904
alkahest 357.67 us 667570 325536 320888

Zero-copy deserialization speed

Format / Lib Access Read Update
abomonation 53.922 us* 55.274 us*
capnp 191.42 ns* 5.6267 us*
flatbuffers 2.5716 ns* 2.5015 ms* 3.7170 us* 2.5026 ms*
rkyv 1.2619 ns* 547.53 us* 148.03 ns* 548.16 us* 4.7230 us
alkahest 1.8977 ns* 29.846 us*

Comparison

Relative to best. Higher is better.

Serialize / deserialize speed and size

Format / Lib Serialize Deserialize Size Zlib Zstd
abomonation 100.00% 93.44%* 27.61% 54.51% 60.40%
bincode 50.98% 72.89% 62.51% 88.53% 85.45%
borsh 49.24% 76.06% 79.78% 90.99% 94.49%
bson 5.50% 17.41% 22.00% 42.07% 60.53%
capnp 39.31% 44.32% 63.35% 70.68%
cbor 18.02% 28.36% 32.11% 61.32% 72.27%
flatbuffers 1.03% 42.21% 61.47% 67.39%
nachricht 6.23% 36.31% 66.49% 75.59% 79.52%
postcard 47.41% 62.39% 100.00% 100.00% 100.00%
prost 7.21%* 19.91%* 27.99% 59.70% 69.53% 73.67%
rkyv 74.44% 100.00%* 79.70%* 59.69% 83.78% 90.25%
rmp 20.39% 54.24% 85.24% 87.10% 88.00%
ron 3.06% 13.35% 24.32% 48.50% 57.59%
serde_json 7.64% 22.80% 21.95% 45.16% 54.97%
simd-json 7.49% 26.84% 21.42% 42.96% 51.53%
speedy 80.00% 88.43% 79.25% 90.70% 94.36%
alkahest 92.34% 53.37% 65.51% 62.02%

Zero-copy deserialization speed

Format / Lib Access Read Update
abomonation 0.00%* 0.27%*
capnp 0.66%* 2.63%*
flatbuffers 49.07%* 0.00%* 3.98%* 0.01%*
rkyv 100.00%* 0.00%* 100.00%* 0.03%* 100.00%
alkahest 66.50%* 0.50%*

Footnotes:

* mouse over for situational details

do not provide deserialization capabilities, but the user can write their own

do not support buffer mutation (capnp and flatbuffers may but not for rust)

rust_serialization_benchmark's People

Contributors

ahmedcharles avatar danielalvsaaker avatar djkoloski avatar repi avatar zakarumych avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.