Copilot commented on code in PR #3410:
URL: https://github.com/apache/dubbo-go/pull/3410#discussion_r3409088443
##########
cluster/loadbalance/util.go:
##########
@@ -28,7 +28,14 @@ import (
// GetWeight returns the weight for the load‑balancing strategy.
func GetWeight(invoker base.Invoker, invocation base.Invocation) int64 {
+ return GetWeightAt(invoker, invocation, time.Now().Unix())
+}
Review Comment:
`GetWeight` now always evaluates `time.Now().Unix()` before it knows whether
warmup logic will run. Previously, the time lookup only happened when `weight >
0`, so this wrapper introduces an extra syscall for zero/negative weights and
is not fully equivalent to the prior behavior.
##########
cluster/loadbalance/util.go:
##########
@@ -46,7 +53,6 @@ func GetWeight(invoker base.Invoker, invocation
base.Invocation) int64 {
// Warm‑up adjustment (same logic as before).
if weight > 0 {
- now := time.Now().Unix()
ts := url.GetParamInt(constant.RemoteTimestampKey, now)
if uptime := now - ts; uptime > 0 {
warm := url.GetParamInt(constant.WarmupKey,
constant.DefaultWarmup)
Review Comment:
`GetWeightAt` assumes `now` is a valid Unix timestamp. If `GetWeight` is
adjusted to pass a sentinel (e.g., 0) to avoid unnecessary time lookups,
`GetWeightAt` should lazily populate `now` before using it in warmup
calculations to preserve the previous semantics.
--
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]