dubbo-go
dubbo-go copied to clipboard
perf(loadbalance): reduce per-select temporary slice allocations
Background
Some load balance implementations allocate temporary slices on each Select call. For common small invoker lists, those allocations can be avoided without changing the selection algorithm.
Examples include weighted random, least-active selection, and alias-method picker construction.
Scope
Reduce temporary allocations in request-time load balance selection while keeping the existing selection semantics unchanged. A conservative approach is to use fixed-size stack arrays for small invoker counts and fall back to heap slices for larger lists.
Relevant code:
cluster/loadbalance/random/loadbalance.gocluster/loadbalance/leastactive/loadbalance.gocluster/loadbalance/aliasmethod/alias_method.go
Acceptance Criteria
- Load balance behavior and existing tests remain unchanged.
- Benchmarks show reduced allocations for representative small and medium invoker counts.
- Avoid introducing long-lived caches in this issue; keep the change local and low-risk.
go test ./cluster/loadbalancepasses.
Please assign to me
close via #3415