Skip to content

Commit 6238bb3

Browse files
committed
Apply client write deadline to batches rather than total flushes
By calculating the write deadline at the beginning of the flush operation, we could be hitting it early if there is a lot of data queued up. Instead this PR applies it to each `writev` batch of at most 1024 vectors, which means that the deadline applies to no more than 64MB in one go. This makes it simpler to tune the write deadline as it can be thought of as "the maximum time taken to allow writing at most 64MB" instead. Signed-off-by: Neil Twigg <[email protected]>
1 parent cd93fef commit 6238bb3

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

server/client.go

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1642,8 +1642,10 @@ func (c *client) flushOutbound() bool {
16421642
}
16431643
consumed := len(wnb)
16441644

1645-
// Actual write to the socket.
1646-
nc.SetWriteDeadline(start.Add(wdl))
1645+
// Actual write to the socket. The deadline applies to each batch
1646+
// rather than the total write, such that the configured deadline
1647+
// can be tuned to a known maximum quantity (64MB).
1648+
nc.SetWriteDeadline(time.Now().Add(wdl))
16471649
wn, err = wnb.WriteTo(nc)
16481650
nc.SetWriteDeadline(time.Time{})
16491651

0 commit comments

Comments
 (0)