mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-16 04:06:44 +00:00
perf(weed/topology): preallocate the disk volume snapshot (#10609)
Disk.GetVolumes copies the disk's whole volume map into a fresh slice, and every caller that walks a node's volumes goes through it: the writable-volume refresh loop every few seconds, ToTopologyInfo on each VolumeList, telemetry, and node unregistration. Growing from nil reallocates and copies about twice the final size each time, which at 100k volumes per disk is 60MB of garbage per call. BenchmarkSyncDataNodeRegistration/100000Volumes 199670102 B/op -> 137728051 B/op
This commit is contained in:
@@ -204,6 +204,7 @@ func (d *Disk) doAddOrUpdateVolume(v storage.VolumeInfo) (isNew, isChanged bool)
|
||||
|
||||
func (d *Disk) GetVolumes() (ret []storage.VolumeInfo) {
|
||||
d.RLock()
|
||||
ret = make([]storage.VolumeInfo, 0, len(d.volumes))
|
||||
for _, v := range d.volumes {
|
||||
ret = append(ret, v)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user