You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We can look into using SPSC channel implementations instead of Tokio's MPSC in some situations. This will decrease contention / synchronization overhead.
Different channel implementations
We make heavy use of Tokio's channels. Should test other channels like Kanal or Flume.
Reducing syscall overhead
Framed and underlying AsyncRead + AsyncWrite IO objects that represent network streams (like TcpStream) are used a lot in msg-rs. They are a useful abstraction, but we should be careful in calling poll_flush or poll_write too often, as this will incur a lot of syscall overhead. There is a trade-off between throughput and latency here. For example, calling poll_flush after every start_send will have the lowest latency but incur a high througput penalty. On the other hand, waiting for the backpressure_boundary to be hit (usually 8KiB), will result in much higher throughput but also higher latency. To give the user some control, every socket should include a flush_interval option that determines the rate at which we should flush our buffers and make the syscall.
Resulted in ~200% speedup in the pubsub benchmark
Reducing TCP latency for small messages
For sending small (<MTU) sized messages over TCP with low latency, make sure to disable Nagle's algorithm by setting set_nodelay(true) on your socket abstraction.
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
This discussion contains a list of all the performance improvements we're thinking about and their results (if applied)
FuturesUnordered
with manualFuture
implementation instead ofJoinSet
for pending requests in the reply driver:msg-rs/msg-socket/src/rep/driver.rs
Line 23 in 380ff65
Box::pin
, which will have an impact as wellreq_res_localhost
benchmarkFramed
and underlyingAsyncRead + AsyncWrite
IO objects that represent network streams (likeTcpStream
) are used a lot in msg-rs. They are a useful abstraction, but we should be careful in callingpoll_flush
orpoll_write
too often, as this will incur a lot of syscall overhead. There is a trade-off between throughput and latency here. For example, callingpoll_flush
after everystart_send
will have the lowest latency but incur a high througput penalty. On the other hand, waiting for thebackpressure_boundary
to be hit (usually 8KiB), will result in much higher throughput but also higher latency. To give the user some control, every socket should include aflush_interval
option that determines the rate at which we should flush our buffers and make the syscall.pubsub
benchmarkset_nodelay(true)
on your socket abstraction.Beta Was this translation helpful? Give feedback.
All reactions