cloudamqp / amq-protocol.cr

An AMQP 0.9.1 serialization library for Crystal
MIT License
10 stars 2 forks source link

Speed up by reading as many bytes as possible and then parse #7

Closed carlhoerberg closed 2 years ago

carlhoerberg commented 2 years ago

Int.from_io will (stack) allocate a buffer and then fill it and then parse, instead now we read as much as possible and then decode each part of a longer byte array.

carlhoerberg commented 2 years ago

LavinMQ using this branch: Average publish rate: 707774.2 msgs/s Average consume rate: 699375.7 msgs/s

master branch: Average publish rate: 637212.4 msgs/s Average consume rate: 636811.7 msgs/s

10% throughput increase

carlhoerberg commented 2 years ago

When only publishing: Average publish rate: 1476317.1 msgs/s

vs. master branch: Average publish rate: 1268211.3 msgs/s

16% increase