From c7c534826e6686b176bdef62531480d860352220 Mon Sep 17 00:00:00 2001 From: Lucas Manning Date: Fri, 12 Jan 2024 18:52:45 -0800 Subject: [PATCH] Set TCPTotalHeaderMaximumSize to 160. Adding extra padding to this value seems to improve performance on gVNIC hardware. When TCPTotalHeaderMaximumSize is <140, 10MB PUT commands start randomly taking 10x as long as they normally do. Fixes #9816 PiperOrigin-RevId: 598024702 --- pkg/tcpip/header/tcp.go | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pkg/tcpip/header/tcp.go b/pkg/tcpip/header/tcp.go index cb9257ad6..fe41e8d49 100644 --- a/pkg/tcpip/header/tcp.go +++ b/pkg/tcpip/header/tcp.go @@ -217,9 +217,13 @@ const ( TCPHeaderMaximumSize = TCPMinimumSize + TCPOptionsMaximumSize // TCPTotalHeaderMaximumSize is the maximum size of headers from all layers in - // a TCP packet. This will need to be updated if we decide to support more - // layer 2 protocols or features like IP tunneling. - TCPTotalHeaderMaximumSize = TCPHeaderMaximumSize + IPv4MaximumHeaderSize + EthernetMaximumSize + // a TCP packet. It analogous to MAX_TCP_HEADER in Linux. + // + // TODO(b/319936470): Investigate why this needs to be at least 140 bytes. In + // Linux this value is at least 160, but in theory we should be able to use + // 138. In practice anything less than 140 starts to break GSO on gVNIC + // hardware. + TCPTotalHeaderMaximumSize = 160 // TCPProtocolNumber is TCP's transport protocol number. TCPProtocolNumber tcpip.TransportProtocolNumber = 6