Skip to main content

IDEAL_BATCH_SIZE

Constant IDEAL_BATCH_SIZE 

Source
pub const IDEAL_BATCH_SIZE: usize = 128;
Expand description

Recommended batch size for packet operations with offload.

This constant defines the optimal number of packets to handle per recv_multiple or send_multiple call. It balances between:

  • Amortizing system call overhead
  • Keeping latency reasonable
  • Memory usage for packet buffers

Based on WireGuard-go’s implementation.

§Example

use tun_rs::IDEAL_BATCH_SIZE;

// Allocate buffers for batch operations
let mut bufs = vec![vec![0u8; 1500]; IDEAL_BATCH_SIZE];
let mut sizes = vec![0; IDEAL_BATCH_SIZE];

See: https://github.com/WireGuard/wireguard-go/blob/master/conn/conn.go#L19