Devolutions / devolutions-gateway

A blazing fast relay server adaptable to different protocols and desired levels of traffic inspection.
Apache License 2.0
69 stars 13 forks source link

perf(jetsocat,dgw): reuse buffer in JMUX sender task #975

Closed CBenoit closed 2 months ago

CBenoit commented 2 months ago

We’re spending a lot of time dealing with Bytes and BytesMut in the JMUX sender task.

image

This patch is getting rid of the leftmost drop. We can actually reuse the BytesMut buffer between writes and greatly reduces allocation / de-allocation.

Performance is increased by ~26.3%.

Before this patch:

0.0000-19.0245 sec 25.2 GBytes 11.4 Gbits/sec

After this patch:

0.0000-17.1307 sec 28.8 GBytes 14.4 Gbits/sec