suzhiking opened a new pull request, #24382:
URL: https://github.com/apache/kafka/pull/24382

   `AssignmentRefinerImpl.refine()` runs on every heartbeat of a stable streams 
group. This PR makes a call cheaper without changing the intermediate 
assignment it derives. It has two commits, each one optimization:
   
   1. Sort only the decisions of the case analysis. To visit the tasks in task 
order, it inverted the target assignment into a `TreeMap` from every stateful 
task to its target active owner, which cost a comparison-based insert per task, 
although a task that is on its target owner produces no decision. The inversion 
is now a `HashMap`, and the staged migrations and the granted tasks are sorted 
by task before they are returned. A task's decision does not depend on the 
order the tasks are visited in, and each list holds a task at most once, so 
both lists are the same as before.
   2. Resolve the stateful subtopologies once per call. Every pass asked, for 
each (member, subtopology) entry it visited, whether the subtopology is 
stateful, and each answer was a lookup in the sorted subtopology map followed 
by a check of its changelog topics. `refine()` now builds the set of stateful 
subtopology IDs once, from the same map with the same test, and the passes test 
membership in that set.
   
   Besides the unit tests, the refiner was compared on 20,000 random groups 
with the refiner as it was before KAFKA-21273 [1/N], including groups that keep 
their active tasks and groups with a member not heard from, with identical 
results.
   
   `AssignmentRefinerBenchmark.refinerImpl`, 1,000 members, 5,000 stateful 
tasks, one standby, MIXED lag, budget 2, µs per call:
   
   | Migrating | Before | After |
   |---|---|---|
   | 0% | 2,419 | 1,568 |
   | 1% | 3,251 | 2,149 |
   | 50% | 5,261 | 4,224 |
   | 100% | 6,160 | 5,718 |
   


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

Reply via email to