You are viewing a plain text version of this content. The canonical link for it is here.
Posted to gitbox@activemq.apache.org by GitBox <gi...@apache.org> on 2021/01/14 20:47:49 UTC

[GitHub] [activemq-artemis] clebertsuconic commented on a change in pull request #3407: ARTEMIS-3067 - track application properties in memory estimate and ch…

clebertsuconic commented on a change in pull request #3407:
URL: https://github.com/apache/activemq-artemis/pull/3407#discussion_r557688999



##########
File path: artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/broker/AMQPStandardMessage.java
##########
@@ -124,12 +124,24 @@ protected ReadableBuffer getData() {
    @Override
    public int getMemoryEstimate() {
       if (memoryEstimate == -1) {
-         memoryEstimate = memoryOffset + (data != null ? data.capacity() : 0);
+         memoryEstimate = memoryOffset + (data != null ? data.capacity() + unmarshalledApplicationPropertiesMemoryEstimateFromData() : 0);
       }
 
       return memoryEstimate;
    }
 
+   private int unmarshalledApplicationPropertiesMemoryEstimateFromData() {
+      if (applicationProperties != null) {
+         // they have been unmarshalled, estimate memory usage based on their encoded size
+         if (remainingBodyPosition != VALUE_NOT_PRESENT) {
+            return remainingBodyPosition - applicationPropertiesPosition;

Review comment:
       it's important to always return the same size...
   
   When the message enters the system, you're adding the size of the message, when leaving you're returning the size after parsing the property.
   
   You need to cache the value, otherwise you would get inconsistencies found by the test suite here:
   
   
    org.apache.activemq.artemis.tests.integration.client.ConsumerTest.testSendReceiveAMQP[isNetty=true, persistent=true]	5.4 sec	1
    org.apache.activemq.artemis.tests.integration.client.ConsumerTest.testSendAMQPReceiveCore[isNetty=true, persistent=true]	5.2 sec	1
    org.apache.activemq.artemis.tests.integration.client.ConsumerTest.testSendAMQPReceiveOpenWire[isNetty=true, persistent=true]	5.3 sec	1
    org.apache.activemq.artemis.tests.integration.client.ConsumerTest.testSendReceiveAMQP[isNetty=true, persistent=false]	5.3 sec	1
    org.apache.activemq.artemis.tests.integration.client.ConsumerTest.testSendAMQPReceiveCore[isNetty=true, persistent=false]	5.2 sec	1
    org.apache.activemq.artemis.tests.integration.client.ConsumerTest.testSendAMQPReceiveOpenWire[isNetty=true, persistent=false]	5.3 sec	1
    org.apache.activemq.artemis.tests.integration.cluster.failover.ReplicatedManyMultipleServerFailoverNoNodeGroupNameTest.testStartLiveFirst




----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org