ARTEMIS-3733 - Destination cache size too small for OpenWire clients

This commit is contained in:
AntonRoskvist 2022-03-25 11:09:24 +01:00 committed by Justin Bertram
parent 84c1feae8c
commit bb44e37e84
No known key found for this signature in database
GPG Key ID: F41830B875BB8633
3 changed files with 24 additions and 2 deletions

View File

@ -136,6 +136,8 @@ public class OpenWireProtocolManager extends AbstractProtocolManager<Command, O
//to management service //to management service
private boolean suppressInternalManagementObjects = true; private boolean suppressInternalManagementObjects = true;
private int openWireDestinationCacheSize = 16;
private final OpenWireFormat wireFormat; private final OpenWireFormat wireFormat;
private final Map<SimpleString, RoutingType> prefixes = new HashMap<>(); private final Map<SimpleString, RoutingType> prefixes = new HashMap<>();
@ -718,6 +720,14 @@ public class OpenWireProtocolManager extends AbstractProtocolManager<Command, O
this.suppressInternalManagementObjects = suppressInternalManagementObjects; this.suppressInternalManagementObjects = suppressInternalManagementObjects;
} }
public int getOpenWireDestinationCacheSize() {
return this.openWireDestinationCacheSize;
}
public void setOpenWireDestinationCacheSize(int openWireDestinationCacheSize) {
this.openWireDestinationCacheSize = openWireDestinationCacheSize;
}
public void setVirtualTopicConsumerWildcards(String virtualTopicConsumerWildcards) { public void setVirtualTopicConsumerWildcards(String virtualTopicConsumerWildcards) {
for (String filter : virtualTopicConsumerWildcards.split(",")) { for (String filter : virtualTopicConsumerWildcards.split(",")) {
String[] configuration = filter.split(";"); String[] configuration = filter.split(";");

View File

@ -200,8 +200,8 @@ public class AMQSession implements SessionCallback {
//lazy allocation of the cache //lazy allocation of the cache
if (existingQueuesCache == null) { 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 //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[16]; existingQueuesCache = new String[protocolManager.getOpenWireDestinationCacheSize()];
assert (Integer.bitCount(existingQueuesCache.length) == 1) : "existingQueuesCache.length must be power of 2"; assert (Integer.bitCount(existingQueuesCache.length) == 1) : "openWireDestinationCacheSize must be a power of 2";
this.existingQueuesCache = existingQueuesCache; this.existingQueuesCache = existingQueuesCache;
} }
final int hashCode = physicalName.hashCode(); final int hashCode = physicalName.hashCode();

View File

@ -81,6 +81,18 @@ The two parameters are configured on an OpenWire `acceptor`, e.g.:
<acceptor name="artemis">tcp://localhost:61616?protocols=OPENWIRE;supportAdvisory=true;suppressInternalManagementObjects=false</acceptor> <acceptor name="artemis">tcp://localhost:61616?protocols=OPENWIRE;supportAdvisory=true;suppressInternalManagementObjects=false</acceptor>
``` ```
## OpenWire Destination Cache
For improved performance of the broker we keep a cache of recently used destinations, so that when new messages are dispatched to them,
we do not have to do a lookup every time. By default, this cache holds up to `16` destinations. If additional destinations are added
they will overwrite older records.
If you are dealing with a large amount of queues you might want to increase this value, which is done via configuration option:
`openWireDestinationCacheSize` set on the OpenWire `acceptor` like this:
```xml
<acceptor name="artemis">tcp://localhost:61616?protocols=OPENWIRE;openWireDestinationCacheSize=64</acceptor>
```
This cache has to be set to a power of 2, i.e.: `2`, `16`, `128` and so on.
## Virtual Topic Consumer Destination Translation ## Virtual Topic Consumer Destination Translation
For existing OpenWire consumers of virtual topic destinations it is possible to For existing OpenWire consumers of virtual topic destinations it is possible to