mirror of
https://github.com/slackhq/nebula.git
synced 2026-09-30 03:16:38 +02:00
respect setting for tun.pin_threads_key (#1861)
This commit is contained in:
@@ -244,10 +244,12 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
|
|||||||
if pinThreads && routines > 1 && len(cpuAffinity) == 0 && !configTest {
|
if pinThreads && routines > 1 && len(cpuAffinity) == 0 && !configTest {
|
||||||
// The operator didn't choose pin CPUs, so pick a default set that
|
// The operator didn't choose pin CPUs, so pick a default set that
|
||||||
// prefers performance cores and doesn't stack co-located instances
|
// prefers performance cores and doesn't stack co-located instances
|
||||||
// onto allowed[0]. The bound UDP port keys the per-instance spread:
|
// onto allowed[0].
|
||||||
// distinct across instances sharing a box, stable across restarts.
|
|
||||||
// A nil result keeps listenIn's stock allowed[i] fallback.
|
// key is used to seed the spreading of routines->cores.
|
||||||
key := uint64(os.Getpid())
|
// use PID if you want to ensure many different Nebulas in VMs or containers land on different cores
|
||||||
|
// use port if you want to always end up on the same cores, ideal for benchmarking.
|
||||||
|
key := uint64(os.Getpid()) //default to PID
|
||||||
pinKeyStr := strings.ToLower(c.GetString("tun.pin_threads_key", ""))
|
pinKeyStr := strings.ToLower(c.GetString("tun.pin_threads_key", ""))
|
||||||
switch pinKeyStr {
|
switch pinKeyStr {
|
||||||
case "":
|
case "":
|
||||||
@@ -255,14 +257,16 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
|
|||||||
case "pid":
|
case "pid":
|
||||||
l.Debug("tun.pin_threads_key is PID")
|
l.Debug("tun.pin_threads_key is PID")
|
||||||
case "port":
|
case "port":
|
||||||
l.Info("tun.pin_threads_key is port number")
|
if ap, err := udpConns[0].LocalAddr(); err == nil && ap.Port() != 0 {
|
||||||
|
l.Info("tun.pin_threads_key is port number")
|
||||||
|
key = uint64(ap.Port())
|
||||||
|
} else {
|
||||||
|
l.Warn("Failed to get a port number for tun.pin_threads_key, falling back to PID", "err", err)
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
l.Warn("tun.pin_threads_key is invalid, using PID")
|
l.Warn("tun.pin_threads_key is invalid, using PID")
|
||||||
}
|
}
|
||||||
|
|
||||||
if ap, err := udpConns[0].LocalAddr(); err == nil && ap.Port() != 0 {
|
|
||||||
key = uint64(ap.Port())
|
|
||||||
}
|
|
||||||
cpuAffinity = cpupick.Default(routines, key, l)
|
cpuAffinity = cpupick.Default(routines, key, l)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user