-
-
Notifications
You must be signed in to change notification settings - Fork 4.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
cmd/syncthing: Add selectable sha256 package (fixes #3613, fixes #3614) #3617
Conversation
This adds autodetection of the fastest hashing library on startup, thus handling the performance regression. It also adds an environment variable to control the selection, STHASHING=standard (Go standard library version, avoids SIGILL crash when the minio library has bugs on odd CPUs), STHASHING=minio (to force using the minio version) or unset for the default autodetection.
We could catch the sigill in monitor, and restart with alternative implementation and potentially set it in stone/config. |
Also, because we are benching both implementations, perhaps it would be nice to print both hashing package performances? |
That's a good idea, didn't think of that, will look into it! |
Regarding the startup hash bench: The bench itself is quite short, and as noted on the forum discussion about the new hash algo. is is short enough to not bump up the CPU up to its full speed (on relatively powerful CPUs). I tested it on few laptops - and unless either the PC is already under load or its on "Crazy Super Performance Power Plan", the clock speed won't bump up to max during the hash test, degrading the results. Ranging from 50MB/s (starting ST when PC is fully idle) up to 300+MB/s (when some CPU core is already busy before launching ST). The point is - it may lead to wrong hash algorithm selection, giving an advantage to whichever one will run last. So it may be a good idea to either make hash test longer, or do few iterations of hash benchs, alternating the algorithm used. |
Good point. It runs three iterations, but first one algo and then the other, and only for 75ms each. They should be interleaved. |
How about running a longer test on first start, then saving the results? You'd need a good strategy for catching people changing their CPU, although I don't imagine that'd be a common occurrence. |
If by first start you mean "the first", when the ID and config are born, it's not optimal: (one of my ST instances is a a portable SyncTrayzor on a portable HDD that travels across bunch of PCs...) |
It doesn't need to be that exhaustive, nobody dies if we get it wrong. A few hundred milliseconds at startup should be sufficient if done correctly. |
Mmkay, so this now does the relevant benchmarking and reporting:
It also detects and acts on SIGILL, but doesn't do anything permanently about it. Also doesn't work when not running with the monitor process, but hey...
Tested the SIGILL handling by changing some random bytes in the sha256 package assembly. |
So does it switch to standard as it crashes? Asking as I see a return statement there. |
Yes. The stdout reader sets the environment variable and returns (instead of continuing to process the rest of the sigill crash). The main loop in the monitor waits for the stdout and stderr readers to complete, then attempts another launch, at which point the STHASHING=standard variable takes effect and the start up works. So it'll crash once on every monitor startup, with the message pointing to github. For those who notice we may get the bug report, for those who don't it should mostly just work. For those who run it under a service with -no-restart they'll come here to complain and we'll have to accept the bug report with CPU details and point towards setting STHASHING=standard. |
@st-review merge |
This adds autodetection of the fastest hashing library on startup, thus handling the performance regression. It also adds an environment variable to control the selection, STHASHING=standard (Go standard library version, avoids SIGILL crash when the minio library has bugs on odd CPUs), STHASHING=minio (to force using the minio version) or unset for the default autodetection. GitHub-Pull-Request: #3617
Purpose
This adds autodetection of the fastest hashing library on startup, thus handling the performance regression. It also adds an environment variable to control the selection, STHASHING=standard (Go standard library version, avoids SIGILL crash when the minio library has bugs on odd CPUs), STHASHING=minio (to force using the minio version) or unset for the default autodetection.
Testing
Works for me...