Skip to content

Commit

Permalink
fix: avoid memory overhead when there is large number of LMQ ConsumeQ…
Browse files Browse the repository at this point in the history
…ueue (#8956)
  • Loading branch information
lizhanhui authored Nov 20, 2024
1 parent c13f051 commit 8505482
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,11 @@ public abstract class AbstractConsumeQueueStore implements ConsumeQueueStoreInte
public AbstractConsumeQueueStore(DefaultMessageStore messageStore) {
this.messageStore = messageStore;
this.messageStoreConfig = messageStore.getMessageStoreConfig();
this.consumeQueueTable = new ConcurrentHashMap<>(32);
if (messageStoreConfig.isEnableLmq()) {
this.consumeQueueTable = new ConcurrentHashMap<>(32_768);
} else {
this.consumeQueueTable = new ConcurrentHashMap<>(32);
}
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,7 +480,13 @@ public long getMaxPhyOffsetInConsumeQueue() throws RocksDBException {
public ConsumeQueueInterface findOrCreateConsumeQueue(String topic, int queueId) {
ConcurrentMap<Integer, ConsumeQueueInterface> map = this.consumeQueueTable.get(topic);
if (null == map) {
ConcurrentMap<Integer, ConsumeQueueInterface> newMap = new ConcurrentHashMap<>(128);
ConcurrentMap<Integer, ConsumeQueueInterface> newMap;
if (MixAll.isLmq(topic)) {
// For LMQ, no need to over allocate internal hashtable
newMap = new ConcurrentHashMap<>(1, 1.0F);
} else {
newMap = new ConcurrentHashMap<>(8);
}
ConcurrentMap<Integer, ConsumeQueueInterface> oldMap = this.consumeQueueTable.putIfAbsent(topic, newMap);
if (oldMap != null) {
map = oldMap;
Expand Down

0 comments on commit 8505482

Please sign in to comment.