Browse Source

fix(syncthing): only perform CPU benchmark on startup when logging enabled, and on goroutine (#10398)

Signed-off-by: Tommy van der Vorst <[email protected]>
Co-authored-by: bt90 <[email protected]>
Tommy van der Vorst 1 month ago
parent
commit
eb4eb7524d
1 changed files with 6 additions and 2 deletions
  1. 6 2
      lib/syncthing/syncthing.go

+ 6 - 2
lib/syncthing/syncthing.go

@@ -162,8 +162,12 @@ func (a *App) startup() error {
 		}()
 	}
 
-	perf := ur.CpuBench(context.Background(), 3, 150*time.Millisecond)
-	slog.Info("Measured hashing performance", "perf", fmt.Sprintf("%.02f MB/s", perf))
+	if slog.Default().Enabled(context.Background(), slog.LevelInfo) {
+		go func() {
+			perf := ur.CpuBench(context.Background(), 3, 150*time.Millisecond)
+			slog.Info("Measured hashing performance", "perf", fmt.Sprintf("%.02f MB/s", perf))
+		}()
+	}
 
 	if a.opts.ResetDeltaIdxs {
 		slog.Info("Reinitializing delta index IDs")