MessageWriterSettings

Settings that affect the way messages are written to a connected socket.

Used as a member in struct TcpMsgSessionSettings.


struct MessageWriterSettings
{
    ssize_t lowerHysteresisSendSize;
    ssize_t upperHysteresisSendSize;
    ssize_t normalCommitBufferSize;
    ssize_t sendSizeUntilBackToNormalBufferSize;
    ssize_t maxSendSize;
};


ssize_t lowerHysteresisSendSize

Sets the 'lower water mark' used for preparing messages in memory. i.e. send requests will be sent until the lower water mark is reached (i.e. there is not enough remaining in the send buffer for it to be worth sending it without first moving that section back to the start of the buffer and seeing if there are more messages that can be prepared in memory).

This value is set according to a compromise between the overhead of issuing a send with a very small buffer, versus the overhead that arises when a memmov is used to copy the remaining unsent data back to the start of the send buffer.

Default value : 128


ssize_t upperHysteresisSendSize

This is the most important parameter affecting performance. It specifies the minimum size for sends using the transport layer.

Sets the 'upper water mark' used for preparing messages in memory. i.e. messages are prepared until the fill position of the buffer exceeds this value.

For very large messages this parameter has no impact on the performance. When sending many small messages the value should be set in order to compromise as follows:

Default value : 4096


ssize_t normalCommitBufferSize

The initial size of the write buffer

Default value : 8192


ssize_t sendSizeUntilBackToNormalBufferSize

A very large message can cause a very large buffer to be allocated. Since this may be an unusual event we want to reset the buffer back to a normal size at an appropriate time rather that use an excessive amount of memory for the life of the session.

Default value : 1024*1024


ssize_t maxSendSize

Imposes an upper bound on the size of a send call.

It is not clear whether this serves any useful purpose, so it should probably just be set to a very large value.

If maxSendSize is too small then the overheads of memmoves can increase because larger messages tend not to be sent in their entirety in a single send call, so ends of messages have to be moved back to the start of the buffer more frequently.

Default value : 65536

Invariant that must be satisified

0 <  lowerHysteresisSendSize
  <= upperHysteresisSendSize
  <= normalCommitBufferSize
  <= maxSendSize

normalCommitBufferSize <= sendSizeUntilBackToNormalBufferSize