mirror of
https://github.com/syncthing/syncthing.git
synced 2025-12-23 22:18:14 -05:00
fix(model): consider number of CPU cores when calculating hashers on interactive OS (#10284) (#10286)
Currently, the number of hashers is always set to 1 on interactive operating systems, which are defined as Windows, macOS, iOS, and Android. However, with modern multicore CPUs, it does not make much sense to limit performance so much. For example, without this fix, a CPU with 16 cores / 32 threads is still limited to using just a single thread to hash files per folder, which may severely affect its performance. For this reason, instead of using a fixed value, calculate the number dynamically, so that it equals one-fourth of the total number of CPU cores. This way, the value of hashes will still end up being just 1 on a slower 4-thread CPU, but it will be allowed to take larger values when the number of threads is higher, increasing hashing performance in the process. Signed-off-by: Tomasz Wilczyński <twilczynski@naver.com> Co-authored-by: Jakob Borg <jakob@kastelo.net>
This commit is contained in:
committed by
GitHub
parent
6ed4cca691
commit
7189a3ebff
@@ -2561,16 +2561,17 @@ func (m *model) numHashers(folder string) int {
|
||||
return folderCfg.Hashers
|
||||
}
|
||||
|
||||
numCpus := runtime.GOMAXPROCS(-1)
|
||||
if build.IsWindows || build.IsDarwin || build.IsIOS || build.IsAndroid {
|
||||
// Interactive operating systems; don't load the system too heavily by
|
||||
// default.
|
||||
return 1
|
||||
numCpus = max(1, numCpus/4)
|
||||
}
|
||||
|
||||
// For other operating systems and architectures, lets try to get some
|
||||
// work done... Divide the available CPU cores among the configured
|
||||
// folders.
|
||||
if perFolder := runtime.GOMAXPROCS(-1) / numFolders; perFolder > 0 {
|
||||
if perFolder := numCpus / numFolders; perFolder > 0 {
|
||||
return perFolder
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user