From 6d4fa27ea709e4c15b89353bd2fa50483ffac5e2 Mon Sep 17 00:00:00 2001 From: Jakob Borg Date: Mon, 23 Jan 2017 21:56:43 +0000 Subject: [PATCH] cmd/syncthing: Report real hashing performance, including weakhash Instead of [I6KAH] 19:05:56 INFO: Single thread hash performance is 359 MB/s using minio/sha256-simd (354 MB/s using crypto/sha256). it now says [I6KAH] 19:06:16 INFO: Single thread SHA256 performance is 359 MB/s using minio/sha256-simd (354 MB/s using crypto/sha256). [I6KAH] 19:06:17 INFO: Actual hashing performance is 299.01 MB/s which is more informative. This is also the number it reports in usage reporting. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/3918 --- cmd/syncthing/main.go | 2 ++ cmd/syncthing/usage_report.go | 16 +++++++++------- lib/sha256/sha256.go | 2 +- 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/cmd/syncthing/main.go b/cmd/syncthing/main.go index f5fbfc3d5..2d09fe5b3 100644 --- a/cmd/syncthing/main.go +++ b/cmd/syncthing/main.go @@ -613,6 +613,8 @@ func syncthingMain(runtimeOptions RuntimeOptions) { sha256.SelectAlgo() sha256.Report() + perf := cpuBench(3, 150*time.Millisecond) + l.Infof("Actual hashing performance is %.02f MB/s", perf) // Emit the Starting event, now that we know who we are. diff --git a/cmd/syncthing/usage_report.go b/cmd/syncthing/usage_report.go index bd011928a..11cf0d92a 100644 --- a/cmd/syncthing/usage_report.go +++ b/cmd/syncthing/usage_report.go @@ -22,7 +22,7 @@ import ( "github.com/syncthing/syncthing/lib/dialer" "github.com/syncthing/syncthing/lib/model" "github.com/syncthing/syncthing/lib/protocol" - "github.com/syncthing/syncthing/lib/sha256" + "github.com/syncthing/syncthing/lib/scanner" "github.com/syncthing/syncthing/lib/upgrade" "github.com/thejerf/suture" ) @@ -291,22 +291,24 @@ func cpuBench(iterations int, duration time.Duration) float64 { perf = v } } + blocksResult = nil return perf } +var blocksResult []protocol.BlockInfo // so the result is not optimized away + func cpuBenchOnce(duration time.Duration) float64 { - chunkSize := 100 * 1 << 10 - h := sha256.New() - bs := make([]byte, chunkSize) + dataSize := 16 * protocol.BlockSize + bs := make([]byte, dataSize) rand.Reader.Read(bs) t0 := time.Now() b := 0 for time.Since(t0) < duration { - h.Write(bs) - b += chunkSize + r := bytes.NewReader(bs) + blocksResult, _ = scanner.Blocks(r, protocol.BlockSize, int64(dataSize), nil, true) + b += dataSize } - h.Sum(nil) d := time.Since(t0) return float64(int(float64(b)/d.Seconds()/(1<<20)*100)) / 100 } diff --git a/lib/sha256/sha256.go b/lib/sha256/sha256.go index 51f489fb4..ab6100b78 100644 --- a/lib/sha256/sha256.go +++ b/lib/sha256/sha256.go @@ -89,7 +89,7 @@ func Report() { otherImpl = defaultImpl } - l.Infof("Single thread hash performance is %s using %s (%s using %s).", formatRate(selectedRate), selectedImpl, formatRate(otherRate), otherImpl) + l.Infof("Single thread SHA256 performance is %s using %s (%s using %s).", formatRate(selectedRate), selectedImpl, formatRate(otherRate), otherImpl) } func selectMinio() {