This adds a new config with the simple and concise name maxConcurrentIncomingRequestKiB. This limits how many bytes we have "in the air" in the form of response data being read and processed. After some testing I think that not having this limiter is seldom a great idea and thus I propose a default value of 256 MiB for this new setting. I also refactored the folder IO limiter to be a model/folder attribute instead of a package global.
This commit is contained in:
@@ -10,6 +10,7 @@ import (
|
||||
"fmt"
|
||||
"runtime"
|
||||
|
||||
"github.com/syncthing/syncthing/lib/protocol"
|
||||
"github.com/syncthing/syncthing/lib/rand"
|
||||
"github.com/syncthing/syncthing/lib/util"
|
||||
)
|
||||
@@ -60,6 +61,7 @@ type OptionsConfiguration struct {
|
||||
StunKeepaliveMinS int `xml:"stunKeepaliveMinS" json:"stunKeepaliveMinS" default:"20"` // 0 for off
|
||||
RawStunServers []string `xml:"stunServer" json:"stunServers" default:"default"`
|
||||
DatabaseTuning Tuning `xml:"databaseTuning" json:"databaseTuning" restart:"true"`
|
||||
RawMaxCIRequestKiB int `xml:"maxConcurrentIncomingRequestKiB" json:"maxConcurrentIncomingRequestKiB"`
|
||||
|
||||
DeprecatedUPnPEnabled bool `xml:"upnpEnabled,omitempty" json:"-"`
|
||||
DeprecatedUPnPLeaseM int `xml:"upnpLeaseMinutes,omitempty" json:"-"`
|
||||
@@ -175,3 +177,26 @@ func (opts OptionsConfiguration) MaxFolderConcurrency() int {
|
||||
// of writing is two, 95-percentile at 12 folders.)
|
||||
return 4 // https://xkcd.com/221/
|
||||
}
|
||||
|
||||
func (opts OptionsConfiguration) MaxConcurrentIncomingRequestKiB() int {
|
||||
// Negative is disabled, which in limiter land is spelled zero
|
||||
if opts.RawMaxCIRequestKiB < 0 {
|
||||
return 0
|
||||
}
|
||||
|
||||
if opts.RawMaxFolderConcurrency == 0 {
|
||||
// The default is 256 MiB
|
||||
return 256 * 1024 // KiB
|
||||
}
|
||||
|
||||
// We can't really do less than a couple of concurrent blocks or we'll
|
||||
// pretty much stall completely. Check that an explicit value is large
|
||||
// enough.
|
||||
const minAllowed = 2 * protocol.MaxBlockSize / 1024
|
||||
if opts.RawMaxCIRequestKiB < minAllowed {
|
||||
return minAllowed
|
||||
}
|
||||
|
||||
// Roll with it.
|
||||
return opts.RawMaxCIRequestKiB
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user