[
https://issues.apache.org/jira/browse/ARTEMIS-2571?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16993017#comment-16993017
]
Sebastian T commented on ARTEMIS-2571:
--------------------------------------
I am attaching a testcase to demonstrate the implications of this PR.
When you run the contained maven project with "mvn clean test", the
Artemis2571_PerfTest will be executed against Artemis 2.10.1.
When you run it with "mvn clean test -Ppatched", the Artemis2571_PerfTest will
be executed against Artemis 2.10.1 and the ActiveMQServerImpl.java file located
under src/test/patch/... will be compiled and used. This file only has the
synchronized keywords removed from the getSessions() methods.
The test establishes 300 connections to the embedded broker with 40 sessions
each. Then 3 separate threads invoke the
ActiveMQServerControl.listConnections() method every 5 seconds to simulate
three open browsers with autorefresh enabled. The execution time of the
listConnections method is measured and printed to the console.
To see if the change has an impact on hot path performance a producer and a
consumer are connected to the broker that read/write from one queue
concurrently.
On my 8 core, 32GB test machine I see no difference in message send/received
between the patched and the unpachted test. But the listConnections() is
executed 50% faster in the patched versions. I.e. 2seconds per instead of 4
seconds per execution.
> Remove unneccessary synchronization in ActiveMQServerImpl
> ---------------------------------------------------------
>
> Key: ARTEMIS-2571
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2571
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Components: Broker, Web Console
> Affects Versions: 2.10.1
> Reporter: Sebastian T
> Priority: Minor
> Attachments: artemis-test.zip
>
> Time Spent: 1.5h
> Remaining Estimate: 0h
>
> The ActiveMQServerImpl sessions field is a ConcurrentHashMap. Synchronizing
> on the ActiveMQServerImpl object to iterate over the map is not necessary.
> ActiveMQServerImpl#getSession, ActiveMQServerImpl#removeSession and
> ActiveMQServerImpl#createSession also work on the sessions field without
> synchronizing on the ActiveMQServerImpl.
> Removing the synchronized keyword on the ActiveMQServerImpl#getSessions()
> methods e.g. improves loading of Connections view, especially when multiple
> administrators are using the UI.
--
This message was sent by Atlassian Jira
(v8.3.4#803005)