device: reduce redundant per-packet overhead in RX path

Peer.RoutineSequentialReceiver() deals with packet vectors and does not
need to perform timer and endpoint operations for every packet in a
given vector. Changing these per-packet operations to per-vector
improves throughput by as much as 10% in some environments.

Signed-off-by: Jordan Whited <jordan@tailscale.com>
This commit is contained in:
Jordan Whited 2023-11-07 15:24:21 -08:00 committed by Jordan Whited
parent 8cc8b8b11b
commit cc193a0b32
2 changed files with 17 additions and 8 deletions

View file

@ -436,7 +436,7 @@ func calculatePaddingSize(packetSize, mtu int) int {
return paddedSize - lastUnit
}
/* Encrypts the elems in the queue
/* Encrypts the elements in the queue
* and marks them for sequential consumption (by releasing the mutex)
*
* Obs. One instance per core
@ -495,7 +495,7 @@ func (peer *Peer) RoutineSequentialSender(maxBatchSize int) {
return
}
if !peer.isRunning.Load() {
// peer has been stopped; return re-usable elemsContainer to the shared pool.
// peer has been stopped; return re-usable elems to the shared pool.
// This is an optimization only. It is possible for the peer to be stopped
// immediately after this check, in which case, elem will get processed.
// The timers and SendBuffers code are resilient to a few stragglers.