Allow deeper sleep (#10883)

Allow each crawler operation to sleep up to 10 seconds on very heavily loaded systems.

This will of course make minimum crawler speed less, but should be more effective at stopping.
This commit is contained in:
Klaus Post 2020-11-12 09:17:56 -08:00 committed by GitHub
parent 1c3590078d
commit f86d3538f6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -775,13 +775,16 @@ func (i *crawlItem) objectPath() string {
return path.Join(i.prefix, i.objectName) return path.Join(i.prefix, i.objectName)
} }
// sleepDuration multiplies the duration d by x and sleeps if is more than 100 micro seconds. // sleepDuration multiplies the duration d by x
// sleep is limited to max 1 second. // and sleeps if is more than 100 micro seconds.
// Sleep is limited to max 15 seconds.
func sleepDuration(d time.Duration, x float64) { func sleepDuration(d time.Duration, x float64) {
const maxWait = 15 * time.Second
const minWait = 100 * time.Microsecond
// Don't sleep for really small amount of time // Don't sleep for really small amount of time
if d := time.Duration(float64(d) * x); d > time.Microsecond*100 { if d := time.Duration(float64(d) * x); d > minWait {
if d > time.Second { if d > maxWait {
d = time.Second d = maxWait
} }
time.Sleep(d) time.Sleep(d)
} }