wangjiacai666 commented on PR #16544:
URL: https://github.com/apache/dubbo/pull/16544#issuecomment-6486384692

   Thanks @EarthChen — both points are addressed in the latest commit (eab03fa).
   
   **1. The other two load balancers.** `LeastActiveLoadBalance` and 
`ShortestResponseLoadBalance` now iterate the list directly as well (`for 
(Invoker<T> invoker : invokers)` with a separate index counter feeding 
`weights[]` / `leastIndexes[]` / `shortestIndexes[]`). The bounded 
`invokers.get(...)` calls in the selection phase are kept. `BitList`'s 
iteration order is identical to its `get(i)` order (ascending bit index, then 
the tail list), so the index bookkeeping — and therefore the selected invoker — 
is unchanged.
   
   `BitList#get(int)` calls per single `select()`, N = 1024:
   
   | class | before | after |
   |---|---|---|
   | `RandomLoadBalance` | 1025 | 1 |
   | `LeastActiveLoadBalance` | 1026 | 2 |
   | `ShortestResponseLoadBalance` | 1025 | 1 |
   
   200 selects on the same 1024-address list: 347 / 355 / 351 ms → 30 / 62 / 38 
ms.
   
   **2. The test did not guard the fix.** Agreed — 3 invokers also pass on the 
old code. I added `testSelectByWeightWithLargeBitList` to all three test 
classes: N = 1024, weighted selection, it asserts the resulting distribution 
*and* that `get(int)` is called fewer than 3 times per selection. A wall-clock 
assertion would be flaky on CI, so the call count is the guard instead. On the 
pre-fix code the three tests fail with `BitList accessed by index 1,026,000 / 
307,500 / 307,500 times` for 1000 / 300 / 300 selects; on the fixed code they 
pass (checked over repeated runs).
   
   Benchmarks and the reproduction detail are also in the PR description now.
   


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