activemq-users mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Tim Bain <tb...@alumni.duke.edu>
Subject Re: More ActiveMQ hotspots.. courtesy of continuous profiling :)
Date Tue, 02 Jun 2015 13:16:30 GMT
Kevin,

Great finds.  What tool were you using?

Is it safe to assume you'll submit patches (when you have time) so we don't
need to capture these in JIRA?

Adding a synchronized Multimap<Consumer, Subscription> to
ManagedRegionBroker looked good to me.  It won't be threadsafe against
simultaneous registers/unregisters for the same subscription, but it looks
like that class already has that problem so I don't think that's a reason
not to do it.

In addConsumerToList(), I think we can do a sorted insertion (iterate
through the list till you find the right place based on the comparator,
then insert) to skip the re-sort.  Either we'll be rolling the list or we
won't, but either way the list will be in sorted order, except that the
minimum element might not be the first one.  So find the minimum element's
index (O(log N), but can be optimized to O(1) for the not-rolling case),
then do a sorted insert starting at that index and wrapping if necessary.
On Jun 1, 2015 9:04 PM, "Kevin Burton" <burton@spinn3r.com> wrote:

> We deployed a continuous profiler at work today and so far the results look
> really interesting.
>
> Definitely worth the investment to setup!
>
> Look like we’re spending 50% of our time here:
>
> org.apache.activemq.broker.jmx.ManagedRegionBroker
>
>     @Override
>     public void removeConsumer(ConnectionContext context, ConsumerInfo
> info) throws Exception {
>         for (Subscription sub : subscriptionMap.keySet()) {
>             if (sub.getConsumerInfo().equals(info)) {
>                // unregister all consumer subs
>                unregisterSubscription(subscriptionMap.get(sub), true);
>             }
>         }
>         super.removeConsumer(context, info);
>     }
>
> … so I think a patch for that could be to keep an index around for a map
> from ConsumerInfo to Subscription… then unregisterSubscription just has to
> factor that in as well.
>
> Another hotspot seems to be:
>
> org.apache.activemq.broker.region.Queue.addToConsumerList(Subscription)
>
> We seem to be spending 5% of our CPU time here due to sorting a list, which
> I think can be eliminated.
>
> But 5% isn’t that bad.
>
> There’s also this:
>
>
> org.apache.activemq.broker.region.AbstractRegion.addSubscriptionsForDestination(ConnectionContext,
> Destination)
>
> but it was a small impact and looks harder to optimize.
>
>
> --
>
> Founder/CEO Spinn3r.com
> Location: *San Francisco, CA*
> blog: http://burtonator.wordpress.com
> … or check out my Google+ profile
> <https://plus.google.com/102718274791889610666/posts>
>

Mime
  • Unnamed multipart/alternative (inline, None, 0 bytes)
View raw message