mirror of
https://github.com/slackhq/nebula.git
synced 2026-08-15 07:26:58 +02:00
tun: default pin_threads off
Thread pinning trades scheduler freedom for TX-ring ordering; that's the right trade on dedicated forwarders but not as a surprise default on hosts sharing cores with other workloads. Make it opt-in and document the default in the example config. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
This commit is contained in:
+3
-2
@@ -264,8 +264,9 @@ tun:
|
|||||||
|
|
||||||
# Linux only. pin_threads pins each tun reader/encrypt OS thread to a single CPU. This keeps every goroutine's
|
# Linux only. pin_threads pins each tun reader/encrypt OS thread to a single CPU. This keeps every goroutine's
|
||||||
# batched sends flowing through one XPS-selected NIC TX ring, so packets within a flow stay ordered on the wire
|
# batched sends flowing through one XPS-selected NIC TX ring, so packets within a flow stay ordered on the wire
|
||||||
# instead of being sprayed across multiple TX rings and reordered. Not reloadable.
|
# instead of being sprayed across multiple TX rings and reordered. Off by default; pinning takes CPUs away from
|
||||||
#pin_threads: true
|
# the scheduler, which can hurt hosts that share cores with other workloads. Not reloadable.
|
||||||
|
#pin_threads: false
|
||||||
|
|
||||||
# Linux only. cpu_affinity overrides which CPUs the tun reader threads pin to: a list of CPU IDs, one per routine
|
# Linux only. cpu_affinity overrides which CPUs the tun reader threads pin to: a list of CPU IDs, one per routine
|
||||||
# (see the top-level `routines` setting). Lists shorter than `routines` are modulo-cycled across the queues; extra
|
# (see the top-level `routines` setting). Lists shorter than `routines` are modulo-cycled across the queues; extra
|
||||||
|
|||||||
+2
-2
@@ -59,7 +59,7 @@ type InterfaceConfig struct {
|
|||||||
// pin-to-(i % NumCPU) behavior. Only consulted when PinThreads is true.
|
// pin-to-(i % NumCPU) behavior. Only consulted when PinThreads is true.
|
||||||
CpuAffinity []int
|
CpuAffinity []int
|
||||||
// PinThreads controls whether each TUN reader OS thread is pinned to a
|
// PinThreads controls whether each TUN reader OS thread is pinned to a
|
||||||
// single CPU (via tun.pin_threads, default true). Pinning keeps each
|
// single CPU (via tun.pin_threads, default false). Pinning keeps each
|
||||||
// goroutine's sendmmsg on one XPS-selected NIC TX ring so per-flow
|
// goroutine's sendmmsg on one XPS-selected NIC TX ring so per-flow
|
||||||
// packets stay ordered on the wire.
|
// packets stay ordered on the wire.
|
||||||
PinThreads bool
|
PinThreads bool
|
||||||
@@ -94,7 +94,7 @@ type Interface struct {
|
|||||||
// Only consulted when pinThreads is true.
|
// Only consulted when pinThreads is true.
|
||||||
cpuAffinity []int
|
cpuAffinity []int
|
||||||
// pinThreads controls whether listenIn pins each TUN reader OS thread to
|
// pinThreads controls whether listenIn pins each TUN reader OS thread to
|
||||||
// a CPU at all (tun.pin_threads, default true). When false, threads are
|
// a CPU at all (tun.pin_threads, default false). When false, threads are
|
||||||
// left free to migrate as on stock nebula.
|
// left free to migrate as on stock nebula.
|
||||||
pinThreads bool
|
pinThreads bool
|
||||||
// ecnEnabled gates RFC 6040 underlay ECN propagation. When true,
|
// ecnEnabled gates RFC 6040 underlay ECN propagation. When true,
|
||||||
|
|||||||
@@ -236,7 +236,7 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
|
|||||||
punchy: punchy,
|
punchy: punchy,
|
||||||
ConntrackCacheTimeout: conntrackCacheTimeout,
|
ConntrackCacheTimeout: conntrackCacheTimeout,
|
||||||
CpuAffinity: parseCpuAffinity(c, l, routines),
|
CpuAffinity: parseCpuAffinity(c, l, routines),
|
||||||
PinThreads: c.GetBool("tun.pin_threads", true),
|
PinThreads: c.GetBool("tun.pin_threads", false),
|
||||||
l: l,
|
l: l,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user