Alanxtl opened a new issue, #3408:
URL: https://github.com/apache/dubbo-go/issues/3408

   ## Background
   
   `loadbalance.GetWeight` calls `time.Now().Unix()` internally. Several load 
balance strategies call `GetWeight` once per invoker during a single `Select`, 
so the current implementation may repeat the same time lookup many times per 
request.
   
   Reusing one timestamp per selection keeps the warmup calculation consistent 
within the same selection and avoids repeated calls to `time.Now()`.
   
   ## Scope
   
   Introduce a small internal helper that accepts the current Unix timestamp, 
and update load balance implementations that loop over invokers to compute 
`now` once per `Select`.
   
   Relevant code:
   
   - `cluster/loadbalance/util.go`
   - `cluster/loadbalance/random/loadbalance.go`
   - `cluster/loadbalance/roundrobin/loadbalance.go`
   - `cluster/loadbalance/leastactive/loadbalance.go`
   - other load balance implementations that repeatedly call `GetWeight`
   
   ## Acceptance Criteria
   
   - Public API compatibility is preserved, including the existing `GetWeight` 
function.
   - Weight and warmup behavior remains equivalent except that one `Select` 
call uses one consistent timestamp.
   - Existing load balance tests pass.
   - Add or update benchmarks if possible to show the effect on selection 
overhead.
   - `go test ./cluster/loadbalance` passes.
   


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to