[ 
https://issues.apache.org/jira/browse/ARTEMIS-4575?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
 ]

Timothy A. Bish updated ARTEMIS-4575:
-------------------------------------
    Affects Version/s: 2.31.2

> Don't start all previous consumers when new consumer added
> ----------------------------------------------------------
>
>                 Key: ARTEMIS-4575
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4575
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>    Affects Versions: 2.31.2
>            Reporter: Josh Byster
>            Priority: Minor
>          Time Spent: 1h 20m
>  Remaining Estimate: 0h
>
> I was running a benchmark to add many consumers, and I see that the marginal 
> cost of adding a new consumer increases due to a linear-time iteration 
> through all the existing consumers with OpenWire. It becomes very slow to add 
> a new consumer when there are already 100k+ on a session, for example. We 
> have thousands of topics and we see a huge performance slowdown due to this.
> More specifically, the stack trace:
> {code:java}
> org.apache.activemq.artemis.utils.ActiveMQThreadFactory$1.run(ActiveMQThreadFactory.java:118)
> java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:628)
> java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1128)
> org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:68)
> org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:32)
> org.apache.activemq.artemis.utils.actors.OrderedExecutor.doTask(OrderedExecutor.java:57)
> org.apache.activemq.artemis.utils.actors.ProcessorBase.executePendingTasks(ProcessorBase.java:68)
> org.apache.activemq.artemis.utils.actors.ThresholdActor.doTask(ThresholdActor.java:73)
> org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection.act(OpenWireConnection.java:369)
> org.apache.activemq.command.ConsumerInfo.visit(ConsumerInfo.java:352)
> org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection$CommandProcessor.processAddConsumer(OpenWireConnection.java:1280)
> org.apache.activemq.artemis.core.protocol.openwire.OpenWireConnection.addConsumer(OpenWireConnection.java:1001)
> org.apache.activemq.artemis.core.protocol.openwire.amq.AMQSession.start(AMQSession.java:257)
> org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.start(ServerSessionImpl.java:1699)
> org.apache.activemq.artemis.core.server.impl.ServerSessionImpl.setStarted(ServerSessionImpl.java:2166)
>    {code}
> {{Most of the time is spent in this method, starting consumers that have 
> previously been started:}}
> {code:java}
> private void setStarted(final boolean s) {
>    Set<ServerConsumer> consumersClone = new HashSet<>(consumers.values());
>    for (ServerConsumer consumer : consumersClone) {
>       consumer.setStarted(s);
>    }
>    started = s;
> } {code}



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to