avoid repeated calls to heavy-weighted viper

This commit is contained in:
chrislu
2024-04-18 09:09:45 -07:00
parent 31f1f96038
commit 55976ae04a
4 changed files with 32 additions and 20 deletions

View File

@@ -303,7 +303,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
// check whether picked file is close to full
dn := locationList.Head()
info, _ := dn.GetVolumesById(vid)
if float64(info.Size) > float64(vl.volumeSizeLimit)*option.Threshold() {
if float64(info.Size) > float64(vl.volumeSizeLimit)*VolumeGrowStrategy.Threshold {
shouldGrow = true
}
return vid, count, locationList.Copy(), shouldGrow, nil
@@ -334,7 +334,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi
vid, locationList = writableVolumeId, volumeLocationList.Copy()
// check whether picked file is close to full
info, _ := dn.GetVolumesById(writableVolumeId)
if float64(info.Size) > float64(vl.volumeSizeLimit)*option.Threshold() {
if float64(info.Size) > float64(vl.volumeSizeLimit)*VolumeGrowStrategy.Threshold {
shouldGrow = true
}
counter = count
@@ -370,7 +370,6 @@ func (vl *VolumeLayout) GetActiveVolumeCount(option *VolumeGrowOption) (total, a
return len(vl.writables), len(vl.writables), len(vl.crowded)
}
total = len(vl.writables)
threshold := option.Threshold()
for _, v := range vl.writables {
for _, dn := range vl.vid2location[v].list {
if dn.GetDataCenter().Id() == NodeId(option.DataCenter) {
@@ -382,7 +381,7 @@ func (vl *VolumeLayout) GetActiveVolumeCount(option *VolumeGrowOption) (total, a
}
active++
info, _ := dn.GetVolumesById(v)
if float64(info.Size) > float64(vl.volumeSizeLimit)*threshold {
if float64(info.Size) > float64(vl.volumeSizeLimit)* VolumeGrowStrategy.Threshold{
crowded++
}
}