This is an automated email from the ASF dual-hosted git repository.

zhaocong pushed a commit to branch branch-2.9
in repository https://gitbox.apache.org/repos/asf/pulsar.git


The following commit(s) were added to refs/heads/branch-2.9 by this push:
     new a1d56d24451 [improve][broker] Use shrink map for trackerCache (#19534)
a1d56d24451 is described below

commit a1d56d2445149000a4653cdb63f6e953e65d801a
Author: xiaolong ran <[email protected]>
AuthorDate: Thu Feb 16 23:18:11 2023 +0800

    [improve][broker] Use shrink map for trackerCache (#19534)
    
    Signed-off-by: xiaolongran <[email protected]>
    (cherry picked from commit c0f89dc981fbe36be834303f13bd09f3b62b3d67)
---
 .../pulsar/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 92df7b3e760..ecfa027bac6 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 @@ package org.apache.pulsar.broker.service;
 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 = 
ConcurrentLongLongPairHashMap.newBuilder()
+            .concurrencyLevel(1)
+            .expectedItems(256)
+            .autoShrink(true)
+            .build();
 
     @Override
     public int incrementAndGetRedeliveryCount(Position position) {

Reply via email to