perf(weed/topology): preallocate the per-disk VolumeList payload (#10614)

ToDiskInfo builds a protobuf message per volume and per ec shard on the disk,
growing both lists from nil. Every VolumeList call runs it for every disk in
the cluster, and the admin dashboard, the plugin worker, several shell commands
and the s3 gateway's per-minute bucket metrics all call VolumeList. Both counts
are already in hand.

ToTopologyInfo over 550k volumes  202.2 MB -> 184.6 MB
This commit is contained in:
Chris Lu
2026-08-07 01:10:57 -07:00
committed by GitHub
parent 0cfca436f1
commit 9f1e21e73f
+2
View File
@@ -311,9 +311,11 @@ func (d *Disk) ToDiskInfo() *master_pb.DiskInfo {
DiskTotalBytes: uint64(max(0, diskUsage.diskTotalBytes)),
DiskFreeBytes: uint64(max(0, diskUsage.diskFreeBytes)),
}
m.VolumeInfos = make([]*master_pb.VolumeInformationMessage, 0, len(volumes))
for _, v := range volumes {
m.VolumeInfos = append(m.VolumeInfos, v.ToVolumeInformationMessage())
}
m.EcShardInfos = make([]*master_pb.VolumeEcShardInformationMessage, 0, len(ecShards))
for _, ecv := range ecShards {
m.EcShardInfos = append(m.EcShardInfos, ecv.ToVolumeEcShardInformationMessage())
}