Adjust batch size in fifo qdisc to match the fdbased batch size.

These two are frequently used together, so this change slightly optimizes
the number of write syscalls.

PiperOrigin-RevId: 463161851
This commit is contained in:
Lucas Manning
2022-07-25 13:21:47 -07:00
committed by gVisor bot
parent 49d88e92ed
commit d542d45a28
2 changed files with 11 additions and 8 deletions
+6 -5
View File
@@ -66,6 +66,11 @@ type linkDispatcher interface {
type PacketDispatchMode int
const (
// BatchSize is the number of packets to write in each syscall. It is 47
// because when GvisorGSO is in use then a single 65KB TCP segment can get
// split into 46 segments of 1420 bytes and a single 216 byte segment.
BatchSize = 47
// Readv is the default dispatch mode and is the least performant of the
// dispatch options but the one that is supported by all underlying FD
// types.
@@ -670,11 +675,7 @@ func (e *endpoint) sendBatch(batchFDInfo fdInfo, pkts []*stack.PacketBuffer) (in
// - pkt.NetworkProtocolNumber
func (e *endpoint) WritePackets(pkts stack.PacketBufferList) (int, tcpip.Error) {
// Preallocate to avoid repeated reallocation as we append to batch.
// batchSz is 47 because when GvisorGSO is in use then a single 65KB TCP
// segment can get split into 46 segments of 1420 bytes and a single 216
// byte segment.
const batchSz = 47
batch := make([]*stack.PacketBuffer, 0, batchSz)
batch := make([]*stack.PacketBuffer, 0, BatchSize)
batchFDInfo := fdInfo{fd: -1, isSocket: false}
sentPackets := 0
for _, pkt := range pkts.AsSlice() {
+5 -3
View File
@@ -28,9 +28,11 @@ import (
var _ stack.QueueingDiscipline = (*discipline)(nil)
const (
// BatchSize represents the number of packets written to the
// lower link endpoint during calls to WritePackets.
BatchSize = 32
// BatchSize is the number of packets to write in each syscall. It is 47
// because when GvisorGSO is in use then a single 65KB TCP segment can get
// split into 46 segments of 1420 bytes and a single 216 byte segment.
BatchSize = 47
qDiscClosed = 1
)