mirror of
https://github.com/octoleo/syncthing.git
synced 2025-02-02 11:58:28 +00:00
cmd/syncthing, lib/sha256: Skip CPU benchmarks when user decided (fixes #4348)
When STHASHING is set, don't benchmark as it's already decided. If weak hashing isn't set to "auto", don't benchmark that either. GitHub-Pull-Request: https://github.com/syncthing/syncthing/pull/4349
This commit is contained in:
parent
9dbc509996
commit
4d3e0de4ba
@ -638,12 +638,10 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
|
|||||||
l.Infoln(LongVersion)
|
l.Infoln(LongVersion)
|
||||||
l.Infoln("My ID:", myID)
|
l.Infoln("My ID:", myID)
|
||||||
|
|
||||||
|
// Select SHA256 implementation and report. Affected by the
|
||||||
|
// STHASHING environment variable.
|
||||||
sha256.SelectAlgo()
|
sha256.SelectAlgo()
|
||||||
sha256.Report()
|
sha256.Report()
|
||||||
perfWithWeakHash := cpuBench(3, 150*time.Millisecond, true)
|
|
||||||
l.Infof("Hashing performance with weak hash is %.02f MB/s", perfWithWeakHash)
|
|
||||||
perfWithoutWeakHash := cpuBench(3, 150*time.Millisecond, false)
|
|
||||||
l.Infof("Hashing performance without weak hash is %.02f MB/s", perfWithoutWeakHash)
|
|
||||||
|
|
||||||
// Emit the Starting event, now that we know who we are.
|
// Emit the Starting event, now that we know who we are.
|
||||||
|
|
||||||
@ -696,6 +694,11 @@ func syncthingMain(runtimeOptions RuntimeOptions) {
|
|||||||
opts := cfg.Options()
|
opts := cfg.Options()
|
||||||
|
|
||||||
if opts.WeakHashSelectionMethod == config.WeakHashAuto {
|
if opts.WeakHashSelectionMethod == config.WeakHashAuto {
|
||||||
|
perfWithWeakHash := cpuBench(3, 150*time.Millisecond, true)
|
||||||
|
l.Infof("Hashing performance with weak hash is %.02f MB/s", perfWithWeakHash)
|
||||||
|
perfWithoutWeakHash := cpuBench(3, 150*time.Millisecond, false)
|
||||||
|
l.Infof("Hashing performance without weak hash is %.02f MB/s", perfWithoutWeakHash)
|
||||||
|
|
||||||
if perfWithoutWeakHash*0.8 > perfWithWeakHash {
|
if perfWithoutWeakHash*0.8 > perfWithWeakHash {
|
||||||
l.Infof("Weak hash disabled, as it has an unacceptable performance impact.")
|
l.Infof("Weak hash disabled, as it has an unacceptable performance impact.")
|
||||||
weakhash.Enabled = false
|
weakhash.Enabled = false
|
||||||
|
@ -55,17 +55,13 @@ func SelectAlgo() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
case "minio":
|
case "minio":
|
||||||
// When set to "minio", use that. Benchmark anyway to be able to
|
// When set to "minio", use that.
|
||||||
// present the difference.
|
|
||||||
benchmark()
|
|
||||||
selectMinio()
|
selectMinio()
|
||||||
|
|
||||||
default:
|
default:
|
||||||
// When set to anything else, such as "standard", use the default Go
|
// When set to anything else, such as "standard", use the default Go
|
||||||
// implementation. Benchmark that anyway, so we can report something
|
// implementation. Make sure not to touch the minio
|
||||||
// useful in Report(). Make sure not to touch the minio
|
|
||||||
// implementation as it may be disabled for incompatibility reasons.
|
// implementation as it may be disabled for incompatibility reasons.
|
||||||
cryptoPerf = cpuBenchOnce(benchmarkingIterations*benchmarkingDuration, cryptoSha256.New)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
verifyCorrectness()
|
verifyCorrectness()
|
||||||
@ -89,6 +85,10 @@ func Report() {
|
|||||||
otherImpl = defaultImpl
|
otherImpl = defaultImpl
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if selectedRate == 0 {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
l.Infof("Single thread SHA256 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)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user