suzhiking opened a new pull request, #24403: URL: https://github.com/apache/kafka/pull/24403
`AssignmentRefinerImpl.refine()` runs on every heartbeat of a stable streams group. This PR makes a call cheaper without changing the intermediate assignment it derives. `refine()` indexed the members' current assignment before its case analysis, which then mapped every stateful target active task to its target owner and skipped each task whose active holder was that owner. A settled group, where every stateful task runs on its target owner, paid for the index and the map on every heartbeat and decided nothing. The new `misplacedTasks` walks the target assignment's stateful active tasks once and keeps those their target owner does not hold as an active task yet. A task that is in place costs one lookup and allocates nothing. When no task is misplaced, `refine()` returns the target assignment before indexing anything. Otherwise the case analysis walks only the misplaced tasks. The derivation is unchanged for a target assignment that names one member for each active task, which the rest of the refiner already assumes. The reconciler grants an active task only when no member holds it as active, so a task has at most one active holder, and the target owner holds a task exactly when it is the task's active holder, which is the test the case analysis used to skip it. 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% | 1,693 | 165 | | 1% | 2,315 | 2,192 | | 50% | 4,652 | 4,588 | | 100% | 6,071 | 5,549 | With nothing migrating, which is the state of a settled group, a call also allocates about 0.03 MB where it allocated 3.16 MB. -- 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]
