only-cliches / NoProto

Flexible, Fast & Compact Serialization with RPC
MIT License
373 stars 14 forks source link

Please use the FlatBufferBuilder reset method #8

Closed rw closed 3 years ago

rw commented 3 years ago

On line https://github.com/only-cliches/NoProto/blob/master/bench/src/run_bench_flatbuffers.rs#L40, using the FlatBufferBuilder::reset method should greatly improve your FlatBuffers write performance. To do this, you'll need to make sure to-reuse a FlatBufferBuilder instead of creating a new one each time through the loop.

only-cliches commented 3 years ago

Hey Robert, thank you for taking the time to look over the benchmark code. My biggest fear in publishing benchmarks is that I haven't taken advantage of each library to it's fullest so this is very helpful!

You're absolutely right, using the reset method increased encoding performance by 3x and update performance by 2.5x!

I'll make sure these results make it to the next release.

Library Encode Decode All Decode 1 Update 1 Size (bytes) Size (Zlib)
Runtime Libs
NoProto 1032 1608 47619 11628 209 167
Apache Avro 158 58 57 40 702 337
FlexBuffers 447 943 25000 294 490 309
JSON 618 489 587 433 439 184
BSON 131 117 125 91 414 216
MessagePack 156 253 264 134 296 187
Compiled Libs
Flatbuffers 3195 16393 250000 2506 264 181
Bincode 6135 9804 10204 4525 163 129
Protobuf 981 1245 1264 546 154 141
Prost 1567 2105 2304 1064 154 142