mirror of
https://github.com/netbirdio/gvisor.git
synced 2026-05-22 17:12:49 -07:00
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:
committed by
gVisor bot
parent
49d88e92ed
commit
d542d45a28
@@ -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() {
|
||||
|
||||
@@ -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
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user