You are viewing a plain text version of this content. The canonical link for it is here.
Posted to issues@activemq.apache.org by "Tim Bain (JIRA)" <ji...@apache.org> on 2015/06/03 15:42:38 UTC

[jira] [Created] (AMQ-5823) Improve performance of AbstractRegion.addSubscriptionsForDestination()

Tim Bain created AMQ-5823:
-----------------------------

             Summary: Improve performance of AbstractRegion.addSubscriptionsForDestination()
                 Key: AMQ-5823
                 URL: https://issues.apache.org/jira/browse/AMQ-5823
             Project: ActiveMQ
          Issue Type: Bug
          Components: Broker
    Affects Versions: 5.11.0
            Reporter: Tim Bain
            Priority: Minor


In a Users mailing list post (http://activemq.2283324.n4.nabble.com/AbstractRegion-addSubscriptionsForDestination-performance-td4697198.html), Kevin Burton pointed out that AbstractRegion.addSubscriptionsForDestination() takes ~8% of his total CPU time.  His scenario's a little unique because he uses far more destinations (and far more consumers) than most installations, but it still highlighted a potential performance improvement.

It appears that the time in that method is spent iterating through all subscriptions and calling matches() on each, which is expensive when N is large and which is wasteful when most/all of those N subscriptions use SimpleDestinationFilters that will match one and only one name (and where in most cases, that destination was already pre-created when the subscription was created, so you're not going to be creating it after the fact).

Maybe we could keep separate lists of subscriptions that use SimpleDestinationFilters (which should always have matched their destination when the subscription was created, so they don't need to be considered when new destinations are created) and of subscriptions that use other DestinationFilter subtypes (which might match new destinations after the fact) and only iterate through the latter list.  If there's a risk that a destination for a SimpleDestinationFilter might not actually have been created ahead of time, then we can use a Multimap<String, Subscription> for the ones that use SimpleDestinationFilters, making it O(1) to find only the ones that match a given name, but I'd hope we don't even need to do that.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)