gpt4 book ai didi

java - JMS 性能和 RemoteTCPConnection.receive

转载 作者:行者123 更新时间:2023-12-01 18:08:29 26 4
gpt4 key购买 nike

并行 JMS 消费者线程后,我没有获得所需的性能提升。
在 jvisualvm 中,我可以看到以下 jms 内容成为 self time CPU 列中的“获胜者”。

com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.receive()

这是线程实际执行的完整堆栈跟踪。

"RcvThread: com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection@9167029[qmid=MWTEST53_2019-06-10_12.32.59,fap=12,channel=MA                  ,ccsid=1208,sharecnv=10,hbint=300,peer=MWTEST/162.11.56.86(1453),localport=61965,ssl=no,hConns=0,LastDataSend=1583310588163 (16ms ago),LastDataRecv=1583310588163 (16ms ago),]" - Thread t@651
java.lang.Thread.State: RUNNABLE
at java.net.SocketInputStream.socketRead0(Native Method)
at java.net.SocketInputStream.socketRead(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at java.net.SocketInputStream.read(Unknown Source)
at com.ibm.mq.jmqi.remote.impl.RemoteTCPConnection.receive(RemoteTCPConnection.java:1535)
at com.ibm.mq.jmqi.remote.impl.RemoteRcvThread.receiveBuffer(RemoteRcvThread.java:794)
at com.ibm.mq.jmqi.remote.impl.RemoteRcvThread.receiveOneTSH(RemoteRcvThread.java:757)
at com.ibm.mq.jmqi.remote.impl.RemoteRcvThread.run(RemoteRcvThread.java:150)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- None

"jms_reader_thread_9" - Thread t@63
java.lang.Thread.State: TIMED_WAITING
at java.lang.Object.wait(Native Method)
- waiting on <711f08> (a com.ibm.mq.jmqi.remote.impl.RemoteProxyQueue$GetterEventMonitor)
at com.ibm.mq.jmqi.remote.impl.RemoteProxyQueue.proxyMQGET(RemoteProxyQueue.java:2492)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiGetInternalWithRecon(RemoteFAP.java:6536)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiGetInternal(RemoteFAP.java:6432)
at com.ibm.mq.jmqi.internal.JmqiTools.getMessage(JmqiTools.java:1259)
at com.ibm.mq.jmqi.remote.api.RemoteFAP.jmqiGet(RemoteFAP.java:6395)
at com.ibm.mq.ese.jmqi.InterceptedJmqiImpl.jmqiGet(InterceptedJmqiImpl.java:910)
at com.ibm.mq.ese.jmqi.ESEJMQI.jmqiGet(ESEJMQI.java:362)
at com.ibm.mq.MQDestination.internalGetMessage(MQDestination.java:1012)
- locked <1a7d0fa> (a com.ibm.mq.MQQueue)
at com.ibm.mq.MQDestination.getInt(MQDestination.java:585)
- locked <1a7d0fa> (a com.ibm.mq.MQQueue)
at com.ibm.mq.MQDestination.get(MQDestination.java:456)
at com.company.app.connection.MqConnection.nextRecordObject(MqConnection.java:351)
at com.company.app.source.AppMqReader.next(AppMqReader.java:37)
at com.company.app.source.AppJMSReadConnector.delegateNext(AppJMSReadConnector.java:202)
at com.company.app.source.LegacyReadConnector.readNextWithRetry(LegacyReadConnector.java:114)
at com.company.app.source.LegacyReadConnector.processNext(LegacyReadConnector.java:68)
at com.company.app.source.AppJMSReadConnector.processNext(AppJMSReadConnector.java:435)
at com.company.app.source.AppReadConnector.next(AppReadConnector.java:131)
at com.company.app.source.AppReadConnector.next(AppReadConnector.java:114)
at com.company.app.configuration.jaxb.ReadPipeline.run(ReadPipeline.java:262)
at com.company.app.configuration.jaxb.AppAdaptor.run(AppAdaptor.java:684)
at com.company.app.configuration.jaxb.RouteService.runOneIteration(RouteService.java:78)
at com.google.common.util.concurrent.AbstractScheduledService$ServiceDelegate$Task.run(AbstractScheduledService.java:195)
at com.google.common.util.concurrent.AbstractScheduledService$CustomScheduler$ReschedulableCallable.call(AbstractScheduledService.java:482)
at com.google.common.util.concurrent.AbstractScheduledService$CustomScheduler$ReschedulableCallable.call(AbstractScheduledService.java:448)
at com.google.common.util.concurrent.Callables$3.call(Callables.java:89)
at java.util.concurrent.FutureTask.run(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$201(Unknown Source)
at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor.runWorker(Unknown Source)
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source)
at java.lang.Thread.run(Unknown Source)

Locked ownable synchronizers:
- locked <cc8421> (a java.util.concurrent.locks.ReentrantLock$NonfairSync)

- locked <15571ee> (a java.util.concurrent.ThreadPoolExecutor$Worker)

线程正在等待!几乎 10 个线程都处于 TIMED_WAITING 状态。这是 receive() 方法逻辑的代码片段

synchronized (this.getterEventMonitor) {
if ((this.status & 0x4) == 0) {
if (waitInterval > 0) {
this.getterEventMonitor.wait(waitInterval);
}
else {

this.getterEventMonitor.wait();
}

}
}

状态 0x4 应为 ST_GETTER_SIGNALLED

问题:等待 ST_GETTER_SIGNALLED 状态背后的逻辑是什么,线程实际在做什么以及如何使其更快?

最佳答案

这不仅仅是一条评论,而且,恕我直言,也比一个答案少一点,但因为对于评论来说,这里的文字太多了。

您确实需要描述线程何时生成并指定工作要做,因为很难找出可能出现的问题,但根据您的陈述,线程大多处于等待状态,那么.. .

...可能发生的情况是,如果所有 10 个线程共享相同的同步逻辑,那么在任何给定点,其中 9 个线程将被锁定在该逻辑之外。第 10 次,将等到您对 (this.status & 0x4) == 0) 的检查成功。

即。如果您的第 10 个线程处于此逻辑中并正在等待,则所有其他 9 个线程将等待第 10 个线程停止等待。

我认为您需要重新设计逻辑,以拥有一个监视事件的调度程序线程,然后将工作单元分派(dispatch)给等待线程。

关于java - JMS 性能和 RemoteTCPConnection.receive,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/60511401/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com