pub fn send_batch(
socket: &UdpSocket,
messages: &[(&[u8], SocketAddr)],
scratch: &mut BatchScratch,
) -> Result<usize, ClockError>Expand description
Send many datagrams in one syscall on Linux (sendmmsg).
The receive side has been batched since M5; the send side was not, so a
server that collected up to 32 requests with one recvmmsg then answered
them with 32 separate sendto calls. Under load the reply path was the
syscall-heavy half of the loop.
It also makes the transmit timestamp more honest for interleaved mode
rather than less: the packets genuinely do leave in one syscall, so one
clock reading taken immediately afterwards describes all of them, where the
old loop stamped each reply after its own sendto and attributed the
accumulated delay of the whole loop to the last client in the batch.
Returns how many datagrams the kernel accepted.