poorbarcode opened a new pull request, #23052:
URL: https://github.com/apache/pulsar/pull/23052

   ### Motivation
   
   `LoadableCache.get` cost too many CPU resources
   
   
[broker_cpu.html.txt](https://github.com/user-attachments/files/16278265/broker_cpu.html.txt)
   
   ```
   pulsar-io-4-20" #135 prio=5 os_prio=0 cpu=79326083.91ms elapsed=1465985.25s 
tid=0x00007f5bc40740b0 nid=0xe9 runnable  [0x00007f5ba51fd000]
      java.lang.Thread.State: RUNNABLE
        at 
java.util.concurrent.ConcurrentLinkedQueue.offer([email protected]/ConcurrentLinkedQueue.java:380)
        at 
java.util.concurrent.ConcurrentLinkedQueue.add([email protected]/ConcurrentLinkedQueue.java:283)
        at 
com.google.common.cache.LocalCache$Segment.recordRead(LocalCache.java:2546)
        at com.google.common.cache.LocalCache$Segment.get(LocalCache.java:2068)
        at com.google.common.cache.LocalCache.get(LocalCache.java:4012)
        at com.google.common.cache.LocalCache.getOrLoad(LocalCache.java:4035)
        at 
com.google.common.cache.LocalCache$LocalLoadingCache.get(LocalCache.java:5011)
        at org.apache.pulsar.common.naming.TopicName.get(TopicName.java:81)
        at 
org.apache.pulsar.common.naming.SystemTopicNames.isEventSystemTopic(SystemTopicNames.java:62)
        at 
org.apache.pulsar.common.naming.SystemTopicNames.isSystemTopic(SystemTopicNames.java:86)
        at 
org.apache.pulsar.common.topics.TopicList.lambda$filterSystemTopic$1(TopicList.java:65)
        at 
org.apache.pulsar.common.topics.TopicList$$Lambda$2132/0x00007f5d049a4800.test(Unknown
 Source)
        at 
java.util.stream.ReferencePipeline$2$1.accept([email protected]/ReferencePipeline.java:178)
        at 
java.util.ArrayList$ArrayListSpliterator.forEachRemaining([email protected]/ArrayList.java:1625)
        at 
java.util.stream.AbstractPipeline.copyInto([email protected]/AbstractPipeline.java:509)
        at 
java.util.stream.AbstractPipeline.wrapAndCopyInto([email protected]/AbstractPipeline.java:499)
        at 
java.util.stream.ReduceOps$ReduceOp.evaluateSequential([email protected]/ReduceOps.java:921)
        at 
java.util.stream.AbstractPipeline.evaluate([email protected]/AbstractPipeline.java:234)
        at 
java.util.stream.ReferencePipeline.collect([email protected]/ReferencePipeline.java:682)
        at 
org.apache.pulsar.common.topics.TopicList.filterSystemTopic(TopicList.java:66)
        at 
org.apache.pulsar.broker.service.ServerCnx.lambda$handleGetTopicsOfNamespace$47(ServerCnx.java:2126)
        at 
org.apache.pulsar.broker.service.ServerCnx$$Lambda$2129/0x00007f5d049b1c80.accept(Unknown
 Source)
        at 
java.util.concurrent.CompletableFuture.uniAcceptNow([email protected]/CompletableFuture.java:757)
        at 
java.util.concurrent.CompletableFuture.uniAcceptStage([email protected]/CompletableFuture.java:735)
        at 
java.util.concurrent.CompletableFuture.thenAccept([email protected]/CompletableFuture.java:2182)
        at 
org.apache.pulsar.broker.service.ServerCnx.lambda$handleGetTopicsOfNamespace$49(ServerCnx.java:2123)
        at 
org.apache.pulsar.broker.service.ServerCnx$$Lambda$2128/0x00007f5d049b1a38.apply(Unknown
 Source)
        at 
java.util.concurrent.CompletableFuture.uniApplyNow([email protected]/CompletableFuture.java:684)
        at 
java.util.concurrent.CompletableFuture.uniApplyStage([email protected]/CompletableFuture.java:662)
        at 
java.util.concurrent.CompletableFuture.thenApply([email protected]/CompletableFuture.java:2168)
        at 
org.apache.pulsar.broker.service.ServerCnx.handleGetTopicsOfNamespace(ServerCnx.java:2120)
        at 
org.apache.pulsar.common.protocol.PulsarDecoder.channelRead(PulsarDecoder.java:315)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at 
io.netty.handler.flow.FlowControlHandler.dequeue(FlowControlHandler.java:202)
        at 
io.netty.handler.flow.FlowControlHandler.channelRead(FlowControlHandler.java:164)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at 
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:346)
        at 
io.netty.handler.codec.ByteToMessageDecoder.fireChannelRead(ByteToMessageDecoder.java:333)
        at 
io.netty.handler.codec.ByteToMessageDecoder.callDecode(ByteToMessageDecoder.java:454)
        at 
io.netty.handler.codec.ByteToMessageDecoder.channelRead(ByteToMessageDecoder.java:290)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:444)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at 
io.netty.handler.flush.FlushConsolidationHandler.channelRead(FlushConsolidationHandler.java:152)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:442)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.AbstractChannelHandlerContext.fireChannelRead(AbstractChannelHandlerContext.java:412)
        at 
io.netty.channel.DefaultChannelPipeline$HeadContext.channelRead(DefaultChannelPipeline.java:1410)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:440)
        at 
io.netty.channel.AbstractChannelHandlerContext.invokeChannelRead(AbstractChannelHandlerContext.java:420)
        at 
io.netty.channel.DefaultChannelPipeline.fireChannelRead(DefaultChannelPipeline.java:919)
        at 
io.netty.channel.epoll.AbstractEpollStreamChannel$EpollStreamUnsafe.epollInReady(AbstractEpollStreamChannel.java:800)
        at 
io.netty.channel.epoll.EpollEventLoop.processReady(EpollEventLoop.java:509)
        at io.netty.channel.epoll.EpollEventLoop.run(EpollEventLoop.java:407)
        at 
io.netty.util.concurrent.SingleThreadEventExecutor$4.run(SingleThreadEventExecutor.java:997)
        at 
io.netty.util.internal.ThreadExecutorMap$2.run(ThreadExecutorMap.java:74)
        at 
io.netty.util.concurrent.FastThreadLocalRunnable.run(FastThreadLocalRunnable.java:30)
        at java.lang.Thread.run([email protected]/Thread.java:840)
   ```
   
   ### Modifications
   
   Because there is no need for a strict invalidate time, change the 
implementation to `ConcurrentHashMap`.
   
   
   
   #### Performance test
   After this PR: 
   - 
[test_merge_request.html.txt](https://github.com/user-attachments/files/16284759/test_merge_request.html.txt)
   
   
   ### Documentation
   
   <!-- DO NOT REMOVE THIS SECTION. CHECK THE PROPER BOX ONLY. -->
   
   - [ ] `doc` <!-- Your PR contains doc changes. -->
   - [ ] `doc-required` <!-- Your PR changes impact docs and you will update 
later -->
   - [x] `doc-not-needed` <!-- Your PR changes do not impact docs -->
   - [ ] `doc-complete` <!-- Docs have been already added -->
   
   ### Matching PR in forked repository
   
   PR in forked repository: x


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