Uploaded image for project: 'Kafka'
  1. Kafka
  2. KAFKA-7344

Return early when all tasks are assigned in StickyTaskAssignor#assignActive

    XMLWordPrintableJSON

Details

    • Improvement
    • Status: Open
    • Minor
    • Resolution: Unresolved
    • None
    • None
    • streams

    Description

      After re-assigning existing active tasks to clients that previously had the same active task, there is chance that taskIds.size() == assigned.size(), i.e. all tasks are assigned .
      The method continues with:

              final Set<TaskId> unassigned = new HashSet<>(taskIds);
              unassigned.removeAll(assigned);
      

      We can check the above condition and return early before allocating HashSet.

      Similar optimization can be done before the following (around line 112):

              // assign any remaining unassigned tasks
              final List<TaskId> sortedTasks = new ArrayList<>(unassigned);
      

      Attachments

        Activity

          People

            chenyuyun-emc kevin.chen
            yuzhihong@gmail.com Ted Yu
            Votes:
            0 Vote for this issue
            Watchers:
            3 Start watching this issue

            Dates

              Created:
              Updated: