wang-jiahua commented on code in PR #10517:
URL: https://github.com/apache/rocketmq/pull/10517#discussion_r3417589517


##########
broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java:
##########
@@ -43,6 +43,21 @@ public class ConsumerOffsetManager extends ConfigManager {
     protected static final Logger LOG = 
LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
     public static final String TOPIC_GROUP_SEPARATOR = "@";
 
+    private final ConcurrentHashMap<String, ConcurrentHashMap<String, String>> 
topicGroupKeyCache = new ConcurrentHashMap<>();
+
+    private String buildTopicGroupKey(String topic, String group) {
+        ConcurrentHashMap<String, String> groupMap = 
topicGroupKeyCache.get(topic);

Review Comment:
   This file has been removed from the PR per reviewer qianye1001 feedback. 
Only TransactionMetricsFlushService busy spin fix remains.



##########
broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java:
##########
@@ -43,6 +43,21 @@ public class ConsumerOffsetManager extends ConfigManager {
     protected static final Logger LOG = 
LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
     public static final String TOPIC_GROUP_SEPARATOR = "@";
 
+    private final ConcurrentHashMap<String, ConcurrentHashMap<String, String>> 
topicGroupKeyCache = new ConcurrentHashMap<>();

Review Comment:
   This file has been removed from the PR per reviewer feedback.



##########
broker/src/main/java/org/apache/rocketmq/broker/offset/ConsumerOffsetManager.java:
##########
@@ -43,6 +43,21 @@ public class ConsumerOffsetManager extends ConfigManager {
     protected static final Logger LOG = 
LoggerFactory.getLogger(LoggerName.BROKER_LOGGER_NAME);
     public static final String TOPIC_GROUP_SEPARATOR = "@";
 
+    private final ConcurrentHashMap<String, ConcurrentHashMap<String, String>> 
topicGroupKeyCache = new ConcurrentHashMap<>();
+
+    private String buildTopicGroupKey(String topic, String group) {
+        ConcurrentHashMap<String, String> groupMap = 
topicGroupKeyCache.get(topic);
+        if (groupMap != null) {
+            String cached = groupMap.get(group);
+            if (cached != null) {
+                return cached;
+            }
+        }
+        String key = topic + TOPIC_GROUP_SEPARATOR + group;
+        topicGroupKeyCache.computeIfAbsent(topic, t -> new 
ConcurrentHashMap<>()).put(group, key);

Review Comment:
   This file has been removed from the PR per reviewer feedback.



##########
broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java:
##########
@@ -58,11 +60,26 @@ public void suspendPullRequest(final String topic, final 
int queueId, final Pull
     }
 
     private String buildKey(final String topic, final int queueId) {
-        StringBuilder sb = new StringBuilder(topic.length() + 5);
-        sb.append(topic);
-        sb.append(TOPIC_QUEUEID_SEPARATOR);
-        sb.append(queueId);
-        return sb.toString();
+        String[] keys = buildKeyCache.get(topic);

Review Comment:
   This file has been removed from the PR per reviewer feedback.



##########
broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java:
##########
@@ -58,11 +60,26 @@ public void suspendPullRequest(final String topic, final 
int queueId, final Pull
     }
 
     private String buildKey(final String topic, final int queueId) {
-        StringBuilder sb = new StringBuilder(topic.length() + 5);
-        sb.append(topic);
-        sb.append(TOPIC_QUEUEID_SEPARATOR);
-        sb.append(queueId);
-        return sb.toString();
+        String[] keys = buildKeyCache.get(topic);
+        if (keys != null && queueId >= 0 && queueId < keys.length) {
+            String cached = keys[queueId];
+            if (cached != null) {
+                return cached;
+            }
+        }
+        String key = topic + TOPIC_QUEUEID_SEPARATOR + queueId;
+        if (topic != null && queueId >= 0) {
+            int len = Math.max(queueId + 1, 16);
+            keys = buildKeyCache.computeIfAbsent(topic, t -> new String[len]);
+            if (queueId >= keys.length) {
+                String[] grown = new String[queueId + 16];

Review Comment:
   This file has been removed from the PR per reviewer feedback.



##########
broker/src/main/java/org/apache/rocketmq/broker/longpolling/PullRequestHoldService.java:
##########
@@ -58,11 +60,26 @@ public void suspendPullRequest(final String topic, final 
int queueId, final Pull
     }
 
     private String buildKey(final String topic, final int queueId) {
-        StringBuilder sb = new StringBuilder(topic.length() + 5);
-        sb.append(topic);
-        sb.append(TOPIC_QUEUEID_SEPARATOR);
-        sb.append(queueId);
-        return sb.toString();
+        String[] keys = buildKeyCache.get(topic);
+        if (keys != null && queueId >= 0 && queueId < keys.length) {
+            String cached = keys[queueId];
+            if (cached != null) {
+                return cached;
+            }
+        }
+        String key = topic + TOPIC_QUEUEID_SEPARATOR + queueId;
+        if (topic != null && queueId >= 0) {
+            int len = Math.max(queueId + 1, 16);
+            keys = buildKeyCache.computeIfAbsent(topic, t -> new String[len]);

Review Comment:
   This file has been removed from the PR per reviewer feedback.



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