From 9b0e636aaa85f8982bf13dfd38ebdb690d4474a8 Mon Sep 17 00:00:00 2001 From: WeebDataHoarder <57538841+WeebDataHoarder@users.noreply.github.com> Date: Tue, 7 Dec 2021 14:54:32 +0100 Subject: [PATCH] Raise default limit to numCPU * 16, max 128 --- SynchRoGazer.go | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/SynchRoGazer.go b/SynchRoGazer.go index 473d2a1..e3933f9 100644 --- a/SynchRoGazer.go +++ b/SynchRoGazer.go @@ -9,7 +9,6 @@ import ( "github.com/minio/sha256-simd" "hash" "io" - "math" "os" "runtime" "strings" @@ -53,7 +52,13 @@ func PrintHashFileResult(result *HashFileResult) { } func main() { - taskLimit := flag.Int("tasklimit", int(math.Ceil(float64(runtime.NumCPU())*1.5)), "Maximum number of concurrent hashing tasks. Change to avoid fdlimit issues. Defaults to number of CPU cores * 1.5") + taskLimit := flag.Int("tasklimit", func() int { + result := runtime.NumCPU() * 16 + if result > 128 { + return 128 + } + return result + }(), "Maximum number of concurrent hashing tasks. Change to avoid fdlimit issues. Defaults to number of min(128, CPU cores * 16)") flag.Parse()