From 4d030871c004c917458b5e1c296edcfc689a2e66 Mon Sep 17 00:00:00 2001 From: Dirk Engling Date: Sat, 31 Oct 2026 15:59:41 +0100 Subject: Make tcp worker multithreaded, too This shamelessly steals the model established in the UDP workers, i.e. if the kernel is able to bind multiple listening sockets to the same endpoint, we will share them across threads. If it can't, all threads will accept on the same socket. The fast path handles most of the connections, only the rare case of no data yet on the socket is offloaded to the slow path (which used to be the mainloop) for completion. This scales nicely, as the higher the load is, the higher chances are that an accept happens only after the network roundtrip to the peer completes, leading to more connections that already have data waiting for us. We also consolidate the workstruct init and deinit code, preparation for later unifying all thread state structs for all protocols (mca, udc and tcp). The config file gains a per tcp connection worker count and some docs explaining what this knob buys and costs, nudging the user to either keep it 0 or dial it up to at least 2. --- opentracker.conf.sample | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) (limited to 'opentracker.conf.sample') diff --git a/opentracker.conf.sample b/opentracker.conf.sample index 1d535e8..f075703 100644 --- a/opentracker.conf.sample +++ b/opentracker.conf.sample @@ -21,9 +21,9 @@ # # A listen statement takes options after the address: # -# workers= handle this udp socket in blocking reads in that -# many dedicated worker threads instead of in the -# event loop. Defaults to 1. Ignored for tcp. +# workers= handle this socket in that many dedicated worker +# threads instead of in the event loop. Defaults to 1 +# for udp and 0 for tcp. # shared allow another process to bind the same address and # let the kernel share the traffic. Only useful if you # deliberately run a second tracker there. @@ -35,6 +35,7 @@ # anywhere. # # listen.udp.workers 4 +# listen.tcp.workers 4 # listen.shared 1 # # Raising the worker count pays off where the kernel spreads arriving -- cgit v1.3