From 3b840c20e3c6ef9f9ed9ac5159251d210b9dd484 Mon Sep 17 00:00:00 2001 From: dsd <60881537+dsd2077@users.noreply.github.com> Date: Wed, 11 Sep 2024 22:39:40 +0800 Subject: [PATCH] =?UTF-8?q?change=20math/rand=20=3D>=20math/rand/v2=20in?= =?UTF-8?q?=20volume=5Flayout.go=20where=20is=20a=20perfo=E2=80=A6=20(#600?= =?UTF-8?q?6)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- weed/topology/volume_layout.go | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/weed/topology/volume_layout.go b/weed/topology/volume_layout.go index 610502769..55827f314 100644 --- a/weed/topology/volume_layout.go +++ b/weed/topology/volume_layout.go @@ -2,12 +2,13 @@ package topology import ( "fmt" - "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" - "math/rand" + "math/rand/v2" "sync" "sync/atomic" "time" + "github.com/seaweedfs/seaweedfs/weed/pb/master_pb" + "github.com/seaweedfs/seaweedfs/weed/storage/types" "github.com/seaweedfs/seaweedfs/weed/glog" @@ -304,7 +305,7 @@ func (vl *VolumeLayout) PickForWrite(count uint64, option *VolumeGrowOption) (vi return 0, 0, nil, true, fmt.Errorf("%s", noWritableVolumes) } if option.DataCenter == "" && option.Rack == "" && option.DataNode == "" { - vid := vl.writables[rand.Intn(lenWriters)] + vid := vl.writables[rand.IntN(lenWriters)] locationList = vl.vid2location[vid] if locationList == nil || len(locationList.list) == 0 { return 0, 0, nil, false, fmt.Errorf("Strangely vid %s is on no machine!", vid.String())