[ https://issues.apache.org/jira/browse/ARTEMIS-4814?focusedWorklogId=923940&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-923940 ]
ASF GitHub Bot logged work on ARTEMIS-4814: ------------------------------------------- Author: ASF GitHub Bot Created on: 18/Jun/24 17:18 Start Date: 18/Jun/24 17:18 Worklog Time Spent: 10m Work Description: clebertsuconic commented on code in PR #4972: URL: https://github.com/apache/activemq-artemis/pull/4972#discussion_r1644812334 ########## artemis-server/src/main/java/org/apache/activemq/artemis/core/postoffice/impl/SimpleAddressManager.java: ########## @@ -100,6 +104,11 @@ public boolean addBinding(final Binding binding) throws Exception { if (nameMap.putIfAbsent(binding.getUniqueName(), bindingAddressPair) != null) { throw ActiveMQMessageBundle.BUNDLE.bindingAlreadyExists(binding); } + directBindingMap.compute(binding.getAddress(), (key, value) -> { + Collection<Binding> bindingList = value == null ? new ArrayList<>() : value; + bindingList.add(binding); Review Comment: Maybe I'm being naive... but as far as I remember.. the ArrayList itself is not supposed to be used from multiple threads. The compute will do a replay, but you could still call the compute from multiple threads. I feel like you should have: ``` synchronized(bindingList) { bindingsList.add(binding); } ``` Or another data structure to be used here. similarly on the remove the queue, it should use a synchronized or use a concurrent equivalent. Issue Time Tracking ------------------- Worklog Id: (was: 923940) Time Spent: 2h 50m (was: 2h 40m) > Remove linear iteration to get direct bindings > ---------------------------------------------- > > Key: ARTEMIS-4814 > URL: https://issues.apache.org/jira/browse/ARTEMIS-4814 > Project: ActiveMQ Artemis > Issue Type: Task > Components: Broker > Reporter: Josh Byster > Priority: Minor > Time Spent: 2h 50m > Remaining Estimate: 0h > > Currently, with 500K+ queues, the cleanup step of {{TempQueueCleanerUpper}} > requires invoking {{WildcardAddressManager#getDirectBindings}}, which is O(k) > in the number of queues. > From method profiling, this can consume up to 95% of our CPU time when > needing to clean up many of these. > It would be nice to make this more efficient, which shouldn't be difficult > given the iteration just does a simple equality check. -- This message was sent by Atlassian Jira (v8.20.10#820010) --------------------------------------------------------------------- To unsubscribe, e-mail: issues-unsubscr...@activemq.apache.org For additional commands, e-mail: issues-h...@activemq.apache.org For further information, visit: https://activemq.apache.org/contact