From 1c10ec8be6fe3ec2d0d1e10fef33a4b1a41dcab7 Mon Sep 17 00:00:00 2001 From: Maisem Ali Date: Wed, 1 May 2024 23:51:24 -0700 Subject: [PATCH] derp,ipn/ipnlocal: stop calling rand.Seed MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit It's deprecated and using it gets us the old slow behavior according to https://go.dev/blog/randv2. > Having eliminated repeatability of the global output stream, Go 1.20 > was also able to make the global generator scale better in programs > that don’t call rand.Seed, replacing the Go 1 generator with a very > cheap per-thread wyrand generator already used inside the Go > runtime. This removed the global mutex and made the top-level > functions scale much better. Programs that do call rand.Seed fall > back to the mutex-protected Go 1 generator. Updates #7123 Change-Id: Ia5452e66bd16b5457d4b1c290a59294545e13291 Signed-off-by: Maisem Ali --- derp/derp_server.go | 4 ---- ipn/ipnlocal/profiles.go | 5 ----- 2 files changed, 9 deletions(-) diff --git a/derp/derp_server.go b/derp/derp_server.go index 1a03012a4..b5085ff10 100644 --- a/derp/derp_server.go +++ b/derp/derp_server.go @@ -69,10 +69,6 @@ func init() { } } -func init() { - rand.Seed(time.Now().UnixNano()) -} - const ( perClientSendQueueDepth = 32 // packets buffered for sending writeTimeout = 2 * time.Second diff --git a/ipn/ipnlocal/profiles.go b/ipn/ipnlocal/profiles.go index 6acdacc30..7643084a9 100644 --- a/ipn/ipnlocal/profiles.go +++ b/ipn/ipnlocal/profiles.go @@ -12,7 +12,6 @@ import ( "runtime" "slices" "strings" - "time" "tailscale.com/clientupdate" "tailscale.com/envknob" @@ -198,10 +197,6 @@ func (pm *profileManager) Reset() { pm.NewProfile() } -func init() { - rand.Seed(time.Now().UnixNano()) -} - // SetPrefs sets the current profile's prefs to the provided value. // It also saves the prefs to the StateStore. It stores a copy of the // provided prefs, which may be accessed via CurrentPrefs.