HarshMehta112 opened a new pull request, #3410:
URL: https://github.com/apache/dubbo-go/pull/3410

   Fixes :  #3408
   
   ### Description
   
     Add `GetWeightAt(invoker, invocation, now int64)` alongside the existing
     `GetWeight` function. Load balance strategies that loop over all invokers 
in
     a single `Select` previously called `time.Now().Unix()` once per invoker
     inside `GetWeight`, repeating the same syscall N times and allowing the
     warmup calculation to drift slightly within a single selection.
   
     `GetWeight` is preserved unchanged as a thin wrapper, keeping the public 
API
     fully compatible. The following strategies now compute `now` once per 
`Select`
     and forward it via `GetWeightAt`: `random`, `roundrobin`, `leastactive`,
     `aliasmethod`, and `iwrr` (init path).
   
     Benchmark (Apple M4 Pro, 255 invokers):
     | Benchmark          | ns/op | B/op | allocs/op |
     |--------------------|-------|------|-----------|
     | BenchmarkGetWeight    | 120.0 | 192  | 4 |
     | BenchmarkGetWeightAt  |  96.2 | 192  | 4 |
     
     ~20% reduction per weight lookup; savings scale linearly with invoker 
count.
   Fixes # (issue)
   
   ### Checklist
   - [x] I confirm the target branch is `develop`
   - [x] Code has passed local testing
   - [x] I have added tests that prove my fix is effective or that my feature 
works
   


-- 
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