lhotari commented on code in PR #24833:
URL: https://github.com/apache/pulsar/pull/24833#discussion_r2429832132


##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/LookupProxyHandler.java:
##########
@@ -357,6 +357,59 @@ private void performGetTopicsOfNamespace(long 
clientRequestId,
         });
     }
 
+    private void internalPerformGetTopicsOfNamespace(long clientRequestId, 
String namespaceName, ClientCnx clientCnx,
+                                                     ByteBuf command, long 
requestId) {
+        BooleanSupplier isPermitRequestCancelled = () -> 
!proxyConnection.ctx().channel().isActive();
+        
maxTopicListInFlightLimiter.withAcquiredPermits(INITIAL_TOPIC_LIST_HEAP_PERMITS_SIZE,
+                AsyncDualMemoryLimiter.LimitType.HEAP_MEMORY, 
isPermitRequestCancelled, initialPermits -> {
+                    return clientCnx.newGetTopicsOfNamespace(command, 
requestId).whenComplete((r, t) -> {
+                        if (t != null) {
+                            log.warn("[{}] Failed to get TopicsOfNamespace {}: 
{}", clientAddress, namespaceName,
+                                    t.getMessage());
+                            writeAndFlush(Commands.newError(clientRequestId, 
getServerError(t), t.getMessage()));
+                        } else {
+                            long actualSize =
+                                    
r.getNonPartitionedOrPartitionTopics().stream().mapToInt(String::length).sum();

Review Comment:
   My assumption is that String are encoded as UTF-8 in the heap. There could 
be multi-byte characters which make the byte count larger than the character 
count. I've revisited the calculation to use byte count for UTF-8 encoding of 
characters.
   I also added 32 byte overhead for each entry in the calculation.
   
   The accuracy isn't that relevant in this case, since the limiter will 
introduce backpressure. The limit should be set to a low enough value so that 
actual resources don't get exhausted when the limit is reached.



-- 
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]

Reply via email to