From 5bd081b90b0efbc0f2b45f544e41127661d969fe Mon Sep 17 00:00:00 2001 From: Ben Cartwright-Cox Date: Fri, 13 Oct 2023 12:18:51 +0100 Subject: [PATCH] Add switch to disable TCP_NODELAY This in an attempt quell CPU usage, since PCCW is having issues when their {N} number of routers all start RTR sessions at the same time. A `perf` of the system suggests all of the CPU is going to sending TCP traffic, and since golang enables NO_DELAY (infamously?) by default, this is a good smoking gun, since this would imply that stayrtr is sending 1 TCP packet per RTR PDU, something that would indeed cause a lot of CPU usage in aggergate! --- lib/server.go | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/lib/server.go b/lib/server.go index 48a8858..05f9755 100644 --- a/lib/server.go +++ b/lib/server.go @@ -536,8 +536,16 @@ func (s *Server) Start(bind string) error { var DisableBGPSec = flag.Bool("disable.bgpsec", false, "Disable sending out BGPSEC Router Keys") var DisableASPA = flag.Bool("disable.aspa", false, "Disable sending out ASPA objects") +var EnableNODELAY = flag.Bool("enable.nodelay", false, "Force enable TCP NODELAY (Likely increases CPU)") func (s *Server) acceptClientTCP(tcpconn net.Conn) error { + if !*EnableNODELAY { + tc, ok := tcpconn.(*net.TCPConn) + if ok { + tc.SetNoDelay(false) + } + } + client := ClientFromConn(tcpconn, s, s) client.log = s.log if s.enforceVersion {