You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pulsar.apache.org by GitBox <gi...@apache.org> on 2022/03/01 13:59:33 UTC

[GitHub] [pulsar] lordcheng10 opened a new pull request #14515: support to shrink for pendingAcks map

lordcheng10 opened a new pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515


   ### Modifications
   issue: https://github.com/apache/pulsar/issues/14268
   
   In order to optimize memory consumption, in the consumer class, the map used by the pendingAcks variable needs to support automatic shrink.
   
   The original pendingAcks variable is defined by the ConcurrentLongLongPairHashMap class of bookkeeper. In order to be independent of the bookkeeper release version, this class is extracted into pulsar as a common class, similar to the ConcurrentLongHashMap class.
   
   See the PR corresponding to bookkeeper: https://github.com/apache/bookkeeper/pull/3061.
   
   
   ### Documentation
   
   Check the box below or label this PR directly (if you have committer privilege).
   
   Need to update docs? 
   
   - [ ] `doc-required` 
     
     (If you need help on updating docs, create a doc issue)
     
   - [x] `no-need-doc` 
     
     (Please explain why)
     
   - [ ] `doc` 
     
     (If this PR contains doc changes)
   
   
   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818279071



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       Aha, I found a solution, the configuration can be accessed in this way in the consumer class:
   subscription.getTopic().getBrokerService()
                              .getPulsar().getConfiguration().isAutoShrinkForConsumerPendingAcksMap()




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1057929836


   @codelipenghui PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] Jason918 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818240403



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       
   ```suggestion
       @Getter
       private boolean autoShrinkForConsumerPendingAcksMap;
   ```
   I think this works.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1057888684


   @Jason918 PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816810553



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       > this is global parameter, maybe you have another way to pass this way.
   every Consumer will use the same value.
   > if you add a "parameter" in the function it means that it would be possible to see different values and this is not true
   
   OK  , I will fix




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816856485



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       Fixed. PTAL,thanks! @eolivelli
   
   rename autoShrink to autoShrinkForConsumerPendingAcksMap;




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816856148



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       Fixed. PTAL,thanks! @eolivelli 
   In the ServerCnx class, define a static variable autoShrinkForConsumerPendingAcksMap instead of passing parameters;




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817508644



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMap.java
##########
@@ -0,0 +1,673 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.common.util.collections;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import java.util.concurrent.locks.StampedLock;
+
+/**
+ * Concurrent hash map where both keys and values are composed of pairs of longs.
+ *
+ * <p>(long,long) --&gt; (long,long)
+ *
+ * <p>Provides similar methods as a {@code ConcurrentMap<K,V>} but since it's an open hash map with linear probing,
+ * no node allocations are required to store the keys and values, and no boxing is required.
+ *
+ * <p>Keys <strong>MUST</strong> be &gt;= 0.
+ */
+public class ConcurrentLongLongPairHashMap {

Review comment:
       Fixed
   @Jason918 PTAL,thanks!




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 edited a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 edited a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1057888684


   @Jason918 PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818249881



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       > I think this works.
   
   The question here is: how do we pass autoShrinkForConsumerPendingAcksMap to the Consumer class, if we don't define autoShrinkForConsumerPendingAcksMap as static and pass the method parameters.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816802472



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       Don't need this configuration? You still need to modify the configuration name, for example: autoShrinkForConcurrentLongLongPairHashMap?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818281068



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       Fixed.
   @eolivelli  PTAL,thanks




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817676174



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       this shouldn't be static




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 edited a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 edited a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1058747405


   @Jason918  @merlimat PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 edited a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 edited a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1058758059


   @merlimat  PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816806141



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       this is global parameter, maybe you have another way to pass this way.
   every Consumer will use the same value.
   
   if you add a "parameter" in the function it means that it would be possible to see different values and this is not true
   
   I believe that overall we don't need a configuration flag at all.
   
   your change is good and you demonstrated that it is needed 
   
   cc @merlimat 




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1055472289


   In order to allow pendingAcks in the consumer to support the automatic shrink capability,
   Here I extract the ConcurrentLongLongPairHashMap class into pulsar separately. @eolivelli @merlimat 


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818247689



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       The problem here is: if you don't define autoShrinkForConsumerPendingAcksMap as static, you can only pass it to the Consumer class by way of method parameters.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817718297



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       Do you have any good ideas?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818279071



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       Aha, I found a solution, the configuration can be accessed in this way in the consumer class:
   
   subscription.getTopic().getBrokerService()
                              .getPulsar().getConfiguration().isAutoShrinkForConsumerPendingAcksMap()




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816804126



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       Do you mean adding the autoShrink parameter directly on the original method?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1058758059


   @merlimat PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 removed a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 removed a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1057929836


   @codelipenghui PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816802472



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       remove this configuration? Or modify the configuration name? like: autoShrinkForConcurrentLongLongPairHashMap?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1056896458


   /pulsarbot run-failure-checks


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816814691



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       > I believe that overall we don't need a configuration flag at all.
   
   Do you think the autoShrink configuration item should not be added? When defining pendingAcks, set it directly to true? For example:
                this.pendingAcks = ConcurrentLongLongPairHashMap.newBuilder()
                        .autoShrink(true)
                        .expectedItems(256)
                        .concurrencyLevel(1)
                        .build();




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817773877



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       In addition to defining static variables, or passing parameters through methods, I have not thought of other ways. @eolivelli Do you have any other good ideas?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 removed a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 removed a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1055472289


   In order to allow pendingAcks in the consumer to support the automatic shrink capability,
   Here I extract the ConcurrentLongLongPairHashMap class into pulsar separately. @eolivelli @merlimat 


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 removed a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 removed a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1057888684


   @Jason918 PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1059717752


   ping


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] Jason918 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r819213628



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       > The question here is: how do we pass autoShrinkForConsumerPendingAcksMap to the Consumer class, if we don't define autoShrinkForConsumerPendingAcksMap as static and pass the method parameters.
   
   What I mean is like the handling of `preciseDispatcherFlowControl`.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 edited a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 edited a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1058758059


   @merlimat @hanbo1990 @codelipenghui PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli merged pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
eolivelli merged pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515


   


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816802472



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       Don't need this configuration? Or modify the configuration name? like: autoShrinkForConcurrentLongLongPairHashMap?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816793595



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       we shouldn't add this knob.
   and if we really want the name should be more narrow and point exactly to the thing that we are changing

##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       I believe that adding a new method for "autoShrink" is not necessary.
   also the variable name should be more meaningful.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 edited a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 edited a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1057888684


   @merlimat @Jason918 PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817422844



##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMap.java
##########
@@ -0,0 +1,673 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.common.util.collections;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import java.util.concurrent.locks.StampedLock;
+
+/**
+ * Concurrent hash map where both keys and values are composed of pairs of longs.
+ *
+ * <p>(long,long) --&gt; (long,long)
+ *
+ * <p>Provides similar methods as a {@code ConcurrentMap<K,V>} but since it's an open hash map with linear probing,
+ * no node allocations are required to store the keys and values, and no boxing is required.
+ *
+ * <p>Keys <strong>MUST</strong> be &gt;= 0.
+ */
+public class ConcurrentLongLongPairHashMap {

Review comment:
       OK




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817508365



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking,"

Review comment:
       Fixed




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1056299565


   /pulsarbot run-failure-checks


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817771821



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       I define static variables in Consumer and initialize them in ServerCnx, what do you think? 
   




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818247689



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       The question here is: how do we pass autoShrinkForConsumerPendingAcksMap to the Consumer class, if we don't define autoShrinkForConsumerPendingAcksMap as static and pass the method parameters.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] Jason918 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
Jason918 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817413259



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking,"

Review comment:
       supports -> enable ?

##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking,"

Review comment:
       And let's add some description about when it's better to enable this auto shinking.

##########
File path: pulsar-common/src/main/java/org/apache/pulsar/common/util/collections/ConcurrentLongLongPairHashMap.java
##########
@@ -0,0 +1,673 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements.  See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership.  The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied.  See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.pulsar.common.util.collections;
+
+import static com.google.common.base.Preconditions.checkArgument;
+import com.google.common.collect.Lists;
+import com.google.common.collect.Maps;
+import java.util.Arrays;
+import java.util.List;
+import java.util.Map;
+import java.util.concurrent.atomic.AtomicIntegerFieldUpdater;
+import java.util.concurrent.locks.StampedLock;
+
+/**
+ * Concurrent hash map where both keys and values are composed of pairs of longs.
+ *
+ * <p>(long,long) --&gt; (long,long)
+ *
+ * <p>Provides similar methods as a {@code ConcurrentMap<K,V>} but since it's an open hash map with linear probing,
+ * no node allocations are required to store the keys and values, and no boxing is required.
+ *
+ * <p>Keys <strong>MUST</strong> be &gt;= 0.
+ */
+public class ConcurrentLongLongPairHashMap {

Review comment:
       I think it's better to copy unit test too.




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817771821



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       I define static variables in Consumer and initialize them in ServerCnx, what do you think? like this:
   ![image](https://user-images.githubusercontent.com/19296967/156386314-99cd4f59-f9f6-4c13-8133-fabe1a6518ec.png)
   ![image](https://user-images.githubusercontent.com/19296967/156386362-62e0a1dc-d9d9-47df-a441-ac69255a37bf.png)
   




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] eolivelli commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
eolivelli commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816804358



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       it is only for pendingAcks at the moment, so the name should reflect it.
   it is not for every ConcurrentLongLongPairHashMap




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1056899973


   /pulsarbot run-failure-checks


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 edited a comment on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 edited a comment on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1058747405


   @Jason918   PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1058747405


   @merlimat PTAL,thanks!


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816810553



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/Topic.java
##########
@@ -161,8 +161,17 @@ default boolean isChunked() {
      * @param option
      * @return
      */
+    @Deprecated
     CompletableFuture<Consumer> subscribe(SubscriptionOption option);
 
+    /**
+     * Subscribe a topic.
+     *
+     * @param autoShrink whether ConcurrentLongLongPairHashMap supports automatic shrinking.
+     * @return
+     */
+    CompletableFuture<Consumer> subscribe(SubscriptionOption option, boolean autoShrink);

Review comment:
       > this is global parameter, maybe you have another way to pass this way.
   every Consumer will use the same value.
   
   if you add a "parameter" in the function it means that it would be possible to see different values and this is not true
   
   OK  , I will fix




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816805668



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       like this?
   autoShrinkForPendingAcks 




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816802472



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       Don't need this configuration? Or modify the configuration name? for example: autoShrinkForConcurrentLongLongPairHashMap?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r816856485



##########
File path: pulsar-broker-common/src/main/java/org/apache/pulsar/broker/ServiceConfiguration.java
##########
@@ -704,6 +704,12 @@
     )
     private boolean isAllowAutoUpdateSchemaEnabled = true;
 
+    @FieldContext(
+            category = CATEGORY_SERVER,
+            doc = "Whether ConcurrentLongLongPairHashMap supports automatic shrinking," +
+                    "the default is false, which means automatic shrinking is not supported.")
+    private boolean autoShrink = false;

Review comment:
       Fixed:
   rename autoShrink to autoShrinkForConsumerPendingAcksMap;




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#issuecomment-1056906139


   /pulsarbot run-failure-checks


-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r818281068



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       Fixed.
   @eolivelli @Jason918 PTAL,thanks




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [pulsar] lordcheng10 commented on a change in pull request #14515: Optimize memory usage: support to shrink for pendingAcks map

Posted by GitBox <gi...@apache.org>.
lordcheng10 commented on a change in pull request #14515:
URL: https://github.com/apache/pulsar/pull/14515#discussion_r817718297



##########
File path: pulsar-broker/src/main/java/org/apache/pulsar/broker/service/ServerCnx.java
##########
@@ -205,6 +205,7 @@
     private boolean autoReadDisabledPublishBufferLimiting = false;
     private final long maxPendingBytesPerThread;
     private final long resumeThresholdPendingBytesPerThread;
+    public static boolean autoShrinkForConsumerPendingAcksMap;

Review comment:
       Do you have any good ideas?




-- 
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: commits-unsubscribe@pulsar.apache.org

For queries about this service, please contact Infrastructure at:
users@infra.apache.org