This is an automated email from the ASF dual-hosted git repository.

Alanxtl pushed a commit to branch develop
in repository https://gitbox.apache.org/repos/asf/dubbo-go.git


The following commit(s) were added to refs/heads/develop by this push:
     new 885bc36c3 perf(registry): pre-size service-discovery maps and slices 
on instance changes (#3414)
885bc36c3 is described below

commit 885bc36c37e727fa68bde7a34429d665a35c0e17
Author: wm_03 <[email protected]>
AuthorDate: Sun Jun 14 13:14:41 2026 +0800

    perf(registry): pre-size service-discovery maps and slices on instance 
changes (#3414)
---
 .../servicediscovery/service_instances_changed_listener_impl.go   | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git 
a/registry/servicediscovery/service_instances_changed_listener_impl.go 
b/registry/servicediscovery/service_instances_changed_listener_impl.go
index 317cff056..427895aeb 100644
--- a/registry/servicediscovery/service_instances_changed_listener_impl.go
+++ b/registry/servicediscovery/service_instances_changed_listener_impl.go
@@ -95,12 +95,11 @@ func (lstn *ServiceInstancesChangedListenerImpl) OnEvent(e 
observer.Event) error
        defer lstn.mutex.Unlock()
 
        lstn.allInstances[ce.ServiceName] = ce.Instances
-       revisionToInstances := make(map[string][]registry.ServiceInstance)
-       newRevisionToMetadata := make(map[string]*info.MetadataInfo)
+       revisionToInstances := make(map[string][]registry.ServiceInstance, 
len(lstn.revisionToMetadata))
+       newRevisionToMetadata := make(map[string]*info.MetadataInfo, 
len(lstn.revisionToMetadata))
        // The same service match key can be exported by several revisions.
        // Keep each revision's ServiceInfo so provider-specific params are not 
collapsed.
-       serviceToRevisionServices := 
make(map[string]map[string]*info.ServiceInfo)
-       newServiceURLs := make(map[string][]*common.URL)
+       serviceToRevisionServices := 
make(map[string]map[string]*info.ServiceInfo, len(lstn.serviceUrls))
 
        logger.Infof("[Registry][ServiceDiscovery] received instance 
notification event, service=%s size=%d", ce.ServiceName, len(ce.Instances))
 
@@ -162,6 +161,7 @@ func (lstn *ServiceInstancesChangedListenerImpl) OnEvent(e 
observer.Event) error
                metaCache.Set(key, metadataInfo)
        }
 
+       newServiceURLs := make(map[string][]*common.URL, 
len(serviceToRevisionServices))
        for serviceKey, revisionServices := range serviceToRevisionServices {
                urls := make([]*common.URL, 0, 8)
                for key, serviceInfo := range revisionServices {

Reply via email to