Adds a new folder state "Waiting to Sync" in the same vein as the existing "Waiting to Scan". This vastly improves performances in the rare cases when there are lots and lots of folders operating.
This commit is contained in:
@@ -8,6 +8,7 @@ package config
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/rand"
|
||||
"github.com/syncthing/syncthing/lib/util"
|
||||
@@ -52,7 +53,7 @@ type OptionsConfiguration struct {
|
||||
TrafficClass int `xml:"trafficClass" json:"trafficClass"`
|
||||
DefaultFolderPath string `xml:"defaultFolderPath" json:"defaultFolderPath" default:"~"`
|
||||
SetLowPriority bool `xml:"setLowPriority" json:"setLowPriority" default:"true"`
|
||||
MaxConcurrentScans int `xml:"maxConcurrentScans" json:"maxConcurrentScans"`
|
||||
RawMaxFolderConcurrency int `xml:"maxFolderConcurrency" json:"maxFolderConcurrency"`
|
||||
CRURL string `xml:"crashReportingURL" json:"crURL" default:"https://crash.syncthing.net/newcrash"` // crash reporting URL
|
||||
CREnabled bool `xml:"crashReportingEnabled" json:"crashReportingEnabled" default:"true" restart:"true"`
|
||||
StunKeepaliveStartS int `xml:"stunKeepaliveStartS" json:"stunKeepaliveStartS" default:"180"` // 0 for off
|
||||
@@ -66,6 +67,7 @@ type OptionsConfiguration struct {
|
||||
DeprecatedUPnPTimeoutS int `xml:"upnpTimeoutSeconds,omitempty" json:"-"`
|
||||
DeprecatedRelayServers []string `xml:"relayServer,omitempty" json:"-"`
|
||||
DeprecatedMinHomeDiskFreePct float64 `xml:"minHomeDiskFreePct,omitempty" json:"-"`
|
||||
DeprecatedMaxConcurrentScans int `xml:"maxConcurrentScans,omitempty" json:"-"`
|
||||
}
|
||||
|
||||
func (opts OptionsConfiguration) Copy() OptionsConfiguration {
|
||||
@@ -152,3 +154,24 @@ func (opts OptionsConfiguration) GlobalDiscoveryServers() []string {
|
||||
}
|
||||
return util.UniqueTrimmedStrings(servers)
|
||||
}
|
||||
|
||||
func (opts OptionsConfiguration) MaxFolderConcurrency() int {
|
||||
// If a value is set, trust that.
|
||||
if opts.RawMaxFolderConcurrency > 0 {
|
||||
return opts.RawMaxFolderConcurrency
|
||||
}
|
||||
if opts.RawMaxFolderConcurrency < 0 {
|
||||
// -1 etc means unlimited, which in the implementation means zero
|
||||
return 0
|
||||
}
|
||||
// Otherwise default to the number of CPU cores in the system as a rough
|
||||
// approximation of system powerfullness.
|
||||
if n := runtime.GOMAXPROCS(-1); n > 0 {
|
||||
return n
|
||||
}
|
||||
// We should never get here to begin with, but since we're here let's
|
||||
// use some sort of reasonable compromise between the old "no limit" and
|
||||
// getting nothing done... (Median number of folders out there at time
|
||||
// of writing is two, 95-percentile at 12 folders.)
|
||||
return 4 // https://xkcd.com/221/
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user