From 70d06134442843cd4355590c4155ee6594558c00 Mon Sep 17 00:00:00 2001 From: Fabricio Voznika Date: Wed, 13 Mar 2019 15:24:09 -0700 Subject: Reduce PACKET_RX_RING memory usage Previous memory allocation was excessive (80 MB). Changed it to use 2 MB instead. There is no drop in perfomance due to this change: ab -n 100 -c 10 http://server/latin10m.txt ==> 10 MB file 80 MB: 178 MB/s 2 MB: 181 MB/s PiperOrigin-RevId: 238321594 Change-Id: I1c8aed13cad5d75f4506d2b406b305117055fbe5 --- pkg/tcpip/link/fdbased/mmap_amd64_unsafe.go | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'pkg') diff --git a/pkg/tcpip/link/fdbased/mmap_amd64_unsafe.go b/pkg/tcpip/link/fdbased/mmap_amd64_unsafe.go index d88c3f8a5..e49cf9f61 100644 --- a/pkg/tcpip/link/fdbased/mmap_amd64_unsafe.go +++ b/pkg/tcpip/link/fdbased/mmap_amd64_unsafe.go @@ -40,11 +40,13 @@ const ( // We overallocate the frame size to accommodate space for the // TPacketHdr+RawSockAddrLinkLayer+MAC header and any padding. // +// Memory allocated for the ring buffer: tpBlockSize * tpBlockNR = 2 MiB +// // NOTE: Frames need to be aligned at 16 byte boundaries. const ( tpFrameSize = 65536 + 128 - tpBlockSize = tpFrameSize * 128 - tpBlockNR = 10 + tpBlockSize = tpFrameSize * 32 + tpBlockNR = 1 tpFrameNR = (tpBlockSize * tpBlockNR) / tpFrameSize ) -- cgit v1.2.3