Improve connectDisks() performance (#9203)

This commit is contained in:
Krishna Srinivas
2020-03-24 23:26:13 -07:00
committed by GitHub
parent 6b984410d5
commit ef6304c5c2
2 changed files with 81 additions and 61 deletions
+5 -4
View File
@@ -24,12 +24,13 @@ import (
)
// getLoadBalancedDisks - fetches load balanced (sufficiently randomized) disk slice.
func (xl xlObjects) getLoadBalancedDisks() (disks []StorageAPI) {
func (xl xlObjects) getLoadBalancedDisks() (newDisks []StorageAPI) {
disks := xl.getDisks()
// Based on the random shuffling return back randomized disks.
for _, i := range hashOrder(UTCNow().String(), len(xl.getDisks())) {
disks = append(disks, xl.getDisks()[i-1])
for _, i := range hashOrder(UTCNow().String(), len(disks)) {
newDisks = append(newDisks, disks[i-1])
}
return disks
return newDisks
}
// This function does the following check, suppose