wang-jiahua commented on code in PR #10528:
URL: https://github.com/apache/rocketmq/pull/10528#discussion_r3429505721
##########
store/src/main/java/org/apache/rocketmq/store/index/IndexService.java:
##########
@@ -49,6 +49,7 @@ public class IndexService implements CommitLogDispatchStore {
private final String storePath;
private final ArrayList<IndexFile> indexFileList = new ArrayList<>();
private final ReadWriteLock readWriteLock = new ReentrantReadWriteLock();
+ private final StringBuilder reusableKeyBuilder = new StringBuilder(128);
Review Comment:
@/tmp/reply-s4-idx.txt
##########
store/src/main/java/org/apache/rocketmq/store/timer/TimerWheel.java:
##########
@@ -55,6 +55,8 @@ protected ByteBuffer initialValue() {
};
private final int wheelLength;
+ private volatile boolean dirty;
Review Comment:
@/tmp/reply-s4-timer.txt
##########
store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java:
##########
@@ -464,47 +470,92 @@ public void incGroupAckNums(final String group, final
String topic, final int in
}
public String buildStatsKey(String topic, String group) {
- StringBuilder strBuilder;
if (topic != null && group != null) {
- strBuilder = new StringBuilder(topic.length() + group.length() +
1);
- } else {
- strBuilder = new StringBuilder();
+ ConcurrentHashMap<String, String> groupMap =
statsKeyByGroupCache.get(topic);
+ if (groupMap != null) {
+ String cached = groupMap.get(group);
+ if (cached != null) {
+ return cached;
+ }
+ }
+ String key = topic + "@" + group;
+ statsKeyByGroupCache.computeIfAbsent(topic, t -> new
ConcurrentHashMap<>()).put(group, key);
+ return key;
}
- strBuilder.append(topic).append("@").append(group);
- return strBuilder.toString();
+ return topic + "@" + group;
}
public String buildStatsKey(String topic, int queueId) {
- StringBuilder strBuilder;
- if (topic != null) {
- strBuilder = new StringBuilder(topic.length() + 5);
- } else {
- strBuilder = new StringBuilder();
+ String[] keys = statsKeyByQueueCache.get(topic);
+ if (keys != null && queueId >= 0 && queueId < keys.length) {
+ String cached = keys[queueId];
+ if (cached != null) {
+ return cached;
+ }
}
- strBuilder.append(topic).append("@").append(queueId);
- return strBuilder.toString();
+ String key = topic + "@" + queueId;
Review Comment:
@/tmp/reply-s4-null.txt
##########
store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java:
##########
@@ -380,32 +386,32 @@ public void onGroupDeleted(final String group) {
this.momentStatsItemSetFallTime.delValueBySuffixKey(group, "@");
}
- public void incQueuePutNums(final String topic, final Integer queueId) {
+ public void incQueuePutNums(final String topic, final int queueId) {
Review Comment:
@/tmp/reply-s4-int.txt
##########
store/src/main/java/org/apache/rocketmq/store/stats/BrokerStatsManager.java:
##########
@@ -141,6 +142,11 @@ public class BrokerStatsManager {
private ScheduledExecutorService cleanResourceExecutor;
private final HashMap<String, StatsItemSet> statsTable = new HashMap<>();
+ private final ConcurrentHashMap<String, String[]> latencyKeyCache = new
ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, String[]> statsKeyByQueueCache =
new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, ConcurrentHashMap<String, String>>
statsKeyByGroupCache = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, ConcurrentHashMap<String,
String[]>> statsKeyByTopicQueueGroupCache = new ConcurrentHashMap<>();
+ private final ConcurrentHashMap<String, ConcurrentHashMap<String,
String[]>> statsKeyByQueueTopicGroupCache = new ConcurrentHashMap<>();
Review Comment:
@/tmp/reply-s4-cache.txt
--
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]