quickfix icon indicating copy to clipboard operation
quickfix copied to clipboard

Escape send queued when blocked on connection side

Open AlexandrosKyriakakis opened this issue 5 months ago • 0 comments

Issue

Observations

  1. Very high lock contention on session.sendMutex
  2. Random huge delays, after sending a message out getting the response taking to match time ~5s in some cases
  3. Main session loop is either sending a batch (and blocking until all messages in the batch are sent) or reading just ONE incoming message.

So, if there are many messages in the slice toSend, session from our side is blocked until all the messages are sent. At the same time, if halfway (when half of the messages in toSend have been sent) the other side cannot accept more messages (maybe cause of a buffer overflow) in order to be unblocked, we need to consume some of the incoming messages, which with the current implementation cannot happen.

Proposed solution

When sending queued messages, if any of the messages cannot be sent, then we escape the toSend loop and leave the rest of the messages for the next session loop.

AlexandrosKyriakakis avatar Jan 30 '24 17:01 AlexandrosKyriakakis