mirror of
https://github.com/seaweedfs/seaweedfs.git
synced 2026-08-16 04:06:44 +00:00
perf(weed/topology): preallocate the client-facing topology snapshots (#10615)
* perf(weed/topology): preallocate the /dir/status volume list
ToVolumeMap boxes every volume on a node into an []interface{} grown from nil,
so the slice reallocates its way up alongside the boxing. The count is known.
* perf(weed/topology): preallocate the volume id list sent to clients
Every filer, s3 gateway, and mount that connects to the master gets one
VolumeLocation per data node carrying that node's whole volume id list, grown
from nil. The count is known.
The ec ids are left alone: shards of one volume can span disks, so the shard
count is an upper bound on the deduped vid count, not the count itself.
This commit is contained in:
@@ -72,8 +72,9 @@ func (t *Topology) ToVolumeMap() interface{} {
|
||||
dataNodes := make(map[NodeId]interface{})
|
||||
for _, d := range rack.Children() {
|
||||
dn := d.(*DataNode)
|
||||
var volumes []interface{}
|
||||
for _, v := range dn.GetVolumes() {
|
||||
dnVolumes := dn.GetVolumes()
|
||||
volumes := make([]interface{}, 0, len(dnVolumes))
|
||||
for _, v := range dnVolumes {
|
||||
volumes = append(volumes, v)
|
||||
}
|
||||
dataNodes[d.Id()] = volumes
|
||||
@@ -99,7 +100,9 @@ func (t *Topology) ToVolumeLocations() (volumeLocations []*master_pb.VolumeLocat
|
||||
DataCenter: dn.GetDataCenterId(),
|
||||
GrpcPort: uint32(dn.GrpcPort),
|
||||
}
|
||||
for _, v := range dn.GetVolumes() {
|
||||
dnVolumes := dn.GetVolumes()
|
||||
volumeLocation.NewVids = make([]uint32, 0, len(dnVolumes))
|
||||
for _, v := range dnVolumes {
|
||||
volumeLocation.NewVids = append(volumeLocation.NewVids, uint32(v.Id))
|
||||
}
|
||||
// A single EC volume's shards can live on multiple disks of
|
||||
|
||||
Reference in New Issue
Block a user