[ 
https://issues.apache.org/jira/browse/ARTEMIS-3771?focusedWorklogId=754655&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-754655
 ]

ASF GitHub Bot logged work on ARTEMIS-3771:
-------------------------------------------

                Author: ASF GitHub Bot
            Created on: 08/Apr/22 15:15
            Start Date: 08/Apr/22 15:15
    Worklog Time Spent: 10m 
      Work Description: AntonRoskvist commented on code in PR #4023:
URL: https://github.com/apache/activemq-artemis/pull/4023#discussion_r846228548


##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/amq/AMQSession.java:
##########
@@ -196,26 +195,22 @@ public boolean 
updateDeliveryCountAfterCancel(ServerConsumer consumer, MessageRe
    private boolean checkCachedExistingQueues(final SimpleString address,
                                              final String physicalName,
                                              final boolean isTemporary) throws 
Exception {
-      String[] existingQueuesCache = this.existingQueuesCache;
       //lazy allocation of the cache
       if (existingQueuesCache == null) {
-         //16 means 64 bytes with 32 bit references or 128 bytes with 64 bit 
references -> 1 or 2 cache lines with common archs
          existingQueuesCache = new 
String[protocolManager.getOpenWireDestinationCacheSize()];
-         assert (Integer.bitCount(existingQueuesCache.length) == 1) : 
"openWireDestinationCacheSize must be a power of 2";
-         this.existingQueuesCache = existingQueuesCache;
       }
-      final int hashCode = physicalName.hashCode();
-      //this.existingQueuesCache.length must be power of 2
-      final int mask = existingQueuesCache.length - 1;
-      final int index = hashCode & mask;
+
+      final int index = Math.floorMod(physicalName.hashCode(), 
existingQueuesCache.length);

Review Comment:
   Yes, but since now there will only be one such calculation per new queue, 
(plus new ones if the cache is full) I figure that might be cheaper overall 
anyway? I changed it because this method has a lower risk of creating identical 
hashes for different values (from my testing at least)...





Issue Time Tracking
-------------------

    Worklog Id:     (was: 754655)
    Time Spent: 40m  (was: 0.5h)

> Rework destination handling for the OpenWire-protocol
> -----------------------------------------------------
>
>                 Key: ARTEMIS-3771
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3771
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Anton Roskvist
>            Priority: Major
>          Time Spent: 40m
>  Remaining Estimate: 0h
>
> Rework destination handling for the OpenWire-protocol
>  
> Mainly improves things for brokers with many destinations and for handling 
> clients not reusing JMS resources, but should be a nice overall improvement 
> for OpenWire.
> Changes are:
> openWireDestinationCache now global, also taking over the role for the 
> connection destination cache
> Avoid calling BindingQuery since that method is expensive when dealing with a 
> large number of destinations
> openwireDestinationCacheSize no longer has to be a power of 2



--
This message was sent by Atlassian Jira
(v8.20.1#820001)

Reply via email to