From 3e87559246c46f196861184f07bed9350024e624 Mon Sep 17 00:00:00 2001 From: xiaolongran Date: Thu, 16 Feb 2023 15:21:27 +0800 Subject: [PATCH 1/3] [improve][broker] Use shrink map for trackerCache Signed-off-by: xiaolongran --- .../broker/service/InMemoryRedeliveryTracker.java | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java index df999ab139d8e..e6567e481f997 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java @@ -21,12 +21,16 @@ import java.util.List; import org.apache.bookkeeper.mledger.Position; import org.apache.bookkeeper.mledger.impl.PositionImpl; -import org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap; -import org.apache.bookkeeper.util.collections.ConcurrentLongLongPairHashMap.LongPair; +import org.apache.pulsar.common.util.collections.ConcurrentLongLongPairHashMap; +import org.apache.pulsar.common.util.collections.ConcurrentLongLongPairHashMap.LongPair; public class InMemoryRedeliveryTracker implements RedeliveryTracker { - private ConcurrentLongLongPairHashMap trackerCache = new ConcurrentLongLongPairHashMap(256, 1); + private ConcurrentLongLongPairHashMap trackerCache = new ConcurrentLongLongPairHashMap.newBuilder() + .concurrencyLevel(2) + .expectedItems(128) + .autoShrink(true) + .build(); @Override public int incrementAndGetRedeliveryCount(Position position) { From f93f4f0de87b88a86dbee5434834a7fc78a9c931 Mon Sep 17 00:00:00 2001 From: xiaolongran Date: Thu, 16 Feb 2023 16:06:14 +0800 Subject: [PATCH 2/3] fix a little Signed-off-by: xiaolongran --- .../apache/pulsar/broker/service/InMemoryRedeliveryTracker.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java index e6567e481f997..fae04e2069bc4 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java @@ -26,7 +26,7 @@ public class InMemoryRedeliveryTracker implements RedeliveryTracker { - private ConcurrentLongLongPairHashMap trackerCache = new ConcurrentLongLongPairHashMap.newBuilder() + private ConcurrentLongLongPairHashMap trackerCache = ConcurrentLongLongPairHashMap.newBuilder() .concurrencyLevel(2) .expectedItems(128) .autoShrink(true) From a897b08e3bdbc88de6638469e757ffbbc84580f9 Mon Sep 17 00:00:00 2001 From: xiaolongran Date: Thu, 16 Feb 2023 18:30:35 +0800 Subject: [PATCH 3/3] fix comments Signed-off-by: xiaolongran --- .../pulsar/broker/service/InMemoryRedeliveryTracker.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java index fae04e2069bc4..8c992d2f7a90b 100644 --- a/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java +++ b/pulsar-broker/src/main/java/org/apache/pulsar/broker/service/InMemoryRedeliveryTracker.java @@ -27,8 +27,8 @@ public class InMemoryRedeliveryTracker implements RedeliveryTracker { private ConcurrentLongLongPairHashMap trackerCache = ConcurrentLongLongPairHashMap.newBuilder() - .concurrencyLevel(2) - .expectedItems(128) + .concurrencyLevel(1) + .expectedItems(256) .autoShrink(true) .build();