You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@seata.apache.org by "0x-infinity (via GitHub)" <gi...@apache.org> on 2025/11/22 08:41:43 UTC

[I] RoundRobinLoadBalance Performance Optimization [incubator-seata-go]

0x-infinity opened a new issue, #994:
URL: https://github.com/apache/incubator-seata-go/issues/994

   ### 讨论详情
   
   ### Description
   In `pkg/remoting/loadbalance/round_robin_loadbalance.go`, each call to `RoundRobinLoadBalance()` creates new map and slice, and performs sorting operations.
   
   **Problem Code**: `pkg/remoting/loadbalance/round_robin_loadbalance.go:31-54`
   ```go
   func RoundRobinLoadBalance(sessions *sync.Map, s string) getty.Session {
       adderToSession := make(map[string]getty.Session, 0)  // create new map each time
       adders := make([]string, 0)                          // create new slice each time
       sessions.Range(func(key, value interface{}) bool {
           session := key.(getty.Session)
           if session.IsClosed() {
               sessions.Delete(key)
           } else {
               adderToSession[session.RemoteAddr()] = session
               adders = append(adders, session.RemoteAddr())
           }
           return true
       })
       sort.Strings(adders)  // sort each time
       // ...
   }
   ```
   
   ### Why Need Improve
   1. Load balancing is a high-frequency operation, triggered on every RPC call
   2. Large number of temporary objects increases GC pressure
   3. Time complexity of sorting each time is O(n log n)
   4. Session list is relatively stable, no need to rebuild each timeRetry
   
   ### 📚 相关背景
   
   _No response_


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [I] RoundRobinLoadBalance Performance Optimization [incubator-seata-go]

Posted by "xuzifu666 (via GitHub)" <gi...@apache.org>.
xuzifu666 commented on issue #994:
URL: https://github.com/apache/incubator-seata-go/issues/994#issuecomment-3566687494

   May i have a try?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org


Re: [I] RoundRobinLoadBalance Performance Optimization [incubator-seata-go]

Posted by "y138g (via GitHub)" <gi...@apache.org>.
y138g commented on issue #994:
URL: https://github.com/apache/incubator-seata-go/issues/994#issuecomment-3566689595

   I'm here


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@seata.apache.org
For additional commands, e-mail: notifications-help@seata.apache.org