You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "squah-confluent (via GitHub)" <gi...@apache.org> on 2026/10/21 11:53:50 UTC
[PR] MINOR: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
squah-confluent opened a new pull request, #23896:
URL: https://github.com/apache/kafka/pull/23896
Pass the share group state partition metadata to ShareGroupSpecBuilder
and look up assignable partitions in a ShareGroupSpecImpl subclass,
instead of copying the initialized partitions into GroupSpecImpl on every
share group assignment, and again for assignor offload. The metadata is
unmodifiable, so no copy is needed.
Co-Authored-By: Claude Opus 5.5 <no...@anthropic.com>
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4379124848
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecImpl.java:
##########
@@ -51,43 +50,26 @@ private record AssignedPartitions(BitSet partitions, int partitionCount) { }
/**
* Member subscription metadata keyed by member Id.
*/
- private final Map<String, MemberSubscriptionAndAssignmentImpl> members;
+ protected final Map<String, MemberSubscriptionAndAssignmentImpl> members;
/**
* The subscription type of the group.
*/
- private final SubscriptionType subscriptionType;
+ protected final SubscriptionType subscriptionType;
/**
* The partitions which are currently assigned to a member,
* keyed by topic id.
*/
private Map<Uuid, AssignedPartitions> assignedTopicPartitions;
Review Comment:
Ah, right... My bad. I thought that it was not needed because it is not used. However, it could be used.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "squah-confluent (via GitHub)" <gi...@apache.org>.
squah-confluent commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4359951467
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecBuilder.java:
##########
@@ -242,22 +269,14 @@ public GroupSpec build() {
))
);
- Optional<Map<Uuid, Set<Integer>>> topicAssignablePartitionsMap = this.topicAssignablePartitionsMap;
if (assignorOffload) {
Review Comment:
We can remove it. I would keep the tests for group spec immutability since we really want that to not break for async assignors.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "squah-confluent (via GitHub)" <gi...@apache.org>.
squah-confluent commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4359957250
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecImpl.java:
##########
@@ -22,19 +22,72 @@
import org.apache.kafka.coordinator.group.api.assignor.MemberAssignment;
import org.apache.kafka.coordinator.group.api.assignor.MemberSubscription;
import org.apache.kafka.coordinator.group.api.assignor.SubscriptionType;
+import org.apache.kafka.coordinator.group.modern.share.ShareGroup.InitMapValue;
import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
/**
* The assignment specification for a modern group.
*/
public class GroupSpecImpl implements GroupSpec {
+ /**
+ * The assignment specification for a share group.
+ */
+ public static class ShareGroupSpecImpl extends GroupSpecImpl {
Review Comment:
Moved `ShareGroupSpecImpl` out to its own file. Are you sure you want `GroupSpecImpl` renamed? I think it's odd for `ShareGroupSpecImpl` to inherit from `ConsumerGroupSpecImpl`.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4422220971
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/ConsumerGroupSpecImpl.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.modern;
+
+import org.apache.kafka.coordinator.common.runtime.CoordinatorMetadataImage;
+import org.apache.kafka.coordinator.group.api.assignor.SubscriptionType;
+
+import java.util.Map;
+
+/**
+ * The assignment specification for a consumer group.
+ */
+public class ConsumerGroupSpecImpl extends GroupSpecImpl {
Review Comment:
I wonder if we should follow the pattern of `GroupSpecBuilder` to be consistent. What do you think? I don't have a strong preference. If we keep the current approach, let's move this one to the `consumer` package and the share one to the `share` package.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "squah-confluent (via GitHub)" <gi...@apache.org>.
squah-confluent commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4379042500
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecImpl.java:
##########
@@ -51,43 +50,26 @@ private record AssignedPartitions(BitSet partitions, int partitionCount) { }
/**
* Member subscription metadata keyed by member Id.
*/
- private final Map<String, MemberSubscriptionAndAssignmentImpl> members;
+ protected final Map<String, MemberSubscriptionAndAssignmentImpl> members;
/**
* The subscription type of the group.
*/
- private final SubscriptionType subscriptionType;
+ protected final SubscriptionType subscriptionType;
/**
* The partitions which are currently assigned to a member,
* keyed by topic id.
*/
private Map<Uuid, AssignedPartitions> assignedTopicPartitions;
Review Comment:
Hm, `ShareGroupSpecImpl.isPartitionAssigned` still needs an implementation and the natural way to do it is the same as for consumer groups. Unless we decide to throw a `NotSupportedException` in `isPartitionAssigned`?
I'm not opposed to defining a `ConsumerGroupSpecImpl` and common `GroupSpecImpl` base class to keep things organized. It's just that I can't see `ConsumerGroupSpecImpl` holding any extra logic right 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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4358195363
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecImpl.java:
##########
@@ -22,19 +22,72 @@
import org.apache.kafka.coordinator.group.api.assignor.MemberAssignment;
import org.apache.kafka.coordinator.group.api.assignor.MemberSubscription;
import org.apache.kafka.coordinator.group.api.assignor.SubscriptionType;
+import org.apache.kafka.coordinator.group.modern.share.ShareGroup.InitMapValue;
import java.util.BitSet;
import java.util.Collection;
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
/**
* The assignment specification for a modern group.
*/
public class GroupSpecImpl implements GroupSpec {
+ /**
+ * The assignment specification for a share group.
+ */
+ public static class ShareGroupSpecImpl extends GroupSpecImpl {
Review Comment:
We usually use this pattern when the top class is abstract. Calling new `GroupSpecImpl.ShareGroupSpecImpl()` feels a bit weird. How about putting `ShareGroupSpecImpl` in its own file and renaming `GroupSpecImpl` to `ConsumerGroupSpecImpl`?
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecBuilder.java:
##########
@@ -242,22 +269,14 @@ public GroupSpec build() {
))
);
- Optional<Map<Uuid, Set<Integer>>> topicAssignablePartitionsMap = this.topicAssignablePartitionsMap;
if (assignorOffload) {
Review Comment:
I wonder whether we should just remove `assignorOffload` now. Dead code looks weird.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4366848886
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecImpl.java:
##########
@@ -51,43 +50,26 @@ private record AssignedPartitions(BitSet partitions, int partitionCount) { }
/**
* Member subscription metadata keyed by member Id.
*/
- private final Map<String, MemberSubscriptionAndAssignmentImpl> members;
+ protected final Map<String, MemberSubscriptionAndAssignmentImpl> members;
/**
* The subscription type of the group.
*/
- private final SubscriptionType subscriptionType;
+ protected final SubscriptionType subscriptionType;
/**
* The partitions which are currently assigned to a member,
* keyed by topic id.
*/
private Map<Uuid, AssignedPartitions> assignedTopicPartitions;
Review Comment:
Seing this, I wonder if we should have ConsumerGroupSpecImpl and move it into it. If we don't want to have topicPartitionAllowedMap in the GroupSpec, it would make sense to remove assignedTopicPartitions too. Have you considered it?
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "squah-confluent (via GitHub) via jira" <ji...@kafka.apache.org>.
squah-confluent commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4445639199
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/ConsumerGroupSpecImpl.java:
##########
@@ -0,0 +1,35 @@
+/*
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements. See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.
+ * The ASF licenses this file to You under the Apache License, Version 2.0
+ * (the "License"); you may not use this file except in compliance with
+ * the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS,
+ * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
+ * See the License for the specific language governing permissions and
+ * limitations under the License.
+ */
+package org.apache.kafka.coordinator.group.modern;
+
+import org.apache.kafka.coordinator.common.runtime.CoordinatorMetadataImage;
+import org.apache.kafka.coordinator.group.api.assignor.SubscriptionType;
+
+import java.util.Map;
+
+/**
+ * The assignment specification for a consumer group.
+ */
+public class ConsumerGroupSpecImpl extends GroupSpecImpl {
Review Comment:
I agree with the reasoning and think we should match the structure of `GroupSpecBuilder`. Moved `ConsumerGroupSpec` and `ShareGroupSpec` into nested classes, without the `Impl` suffix.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] MINOR: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "squah-confluent (via GitHub)" <gi...@apache.org>.
squah-confluent commented on PR #23896:
URL: https://github.com/apache/kafka/pull/23896#issuecomment-6315258372
This PR is stacked on top of #23883 and #23888, which are its first two commits. Only the last commit, 93f9b64043, is new here.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "squah-confluent (via GitHub) via jira" <ji...@kafka.apache.org>.
squah-confluent merged PR #23896:
URL: https://github.com/apache/kafka/pull/23896
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] KAFKA-20292: Avoid copying share group assignable partitions in GroupSpecBuilder [kafka]
Posted by "dajac (via GitHub)" <gi...@apache.org>.
dajac commented on code in PR #23896:
URL: https://github.com/apache/kafka/pull/23896#discussion_r4422226992
##########
group-coordinator/src/main/java/org/apache/kafka/coordinator/group/modern/GroupSpecImpl.java:
##########
@@ -28,13 +28,12 @@
import java.util.HashMap;
import java.util.Map;
import java.util.Objects;
-import java.util.Optional;
import java.util.Set;
/**
* The assignment specification for a modern group.
*/
-public class GroupSpecImpl implements GroupSpec {
+public abstract class GroupSpecImpl implements GroupSpec {
Review Comment:
If we keep this file alone (see my previous comment), we should name it `AbstractGroupSpec` or something like this. It is not an full implementation anymore.
--
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: jira-unsubscribe@kafka.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org