From 30f3409d4f259ad519f832591de22a159ab37ea5 Mon Sep 17 00:00:00 2001 From: Kevin Krakauer Date: Tue, 13 Jun 2023 18:04:58 -0700 Subject: [PATCH] netstack: use unix.Syscall instead of BlockingPoll MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit unix.Syscall increases throughput and decreases CPU usage. ``` │ /tmp/old.log │ /tmp/new.log │ │ Mb/s │ Mb/s vs base │ TCPClient/role=server/host-gso=true/host-gro=true 13.61k ± 2% 13.93k ± 1% +2.35% (p=0.000 n=10) TCPClient/role=client/host-gso=true/host-gro=true 2.300k ± 1% 2.369k ± 1% +3.00% (p=0.000 n=10) geomean 5.595k 5.745k +2.67% │ /tmp/old.log │ /tmp/new.log │ │ cpu-time │ cpu-time vs base │ TCPClient/role=server/host-gso=true/host-gro=true 2.410 ± 0% 2.299 ± 1% -4.62% (p=0.000 n=10) TCPClient/role=client/host-gso=true/host-gro=true 2.883 ± 0% 2.802 ± 1% -2.81% (p=0.000 n=10) geomean 2.636 2.538 -3.72% ``` PiperOrigin-RevId: 540128696 --- pkg/tcpip/link/rawfile/rawfile_unsafe.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pkg/tcpip/link/rawfile/rawfile_unsafe.go b/pkg/tcpip/link/rawfile/rawfile_unsafe.go index e53789d92..6fd17a0bd 100644 --- a/pkg/tcpip/link/rawfile/rawfile_unsafe.go +++ b/pkg/tcpip/link/rawfile/rawfile_unsafe.go @@ -245,7 +245,7 @@ func BlockingPollUntilStopped(efd int, fd int, events int16) (bool, unix.Errno) Events: events, }, } - _, errno := BlockingPoll(&pevents[0], len(pevents), nil) + _, _, errno := unix.Syscall6(unix.SYS_PPOLL, uintptr(unsafe.Pointer(&pevents[0])), uintptr(len(pevents)), 0, 0, 0, 0) if errno != 0 { return pevents[0].Revents&unix.POLLIN != 0, errno }