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

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

                Author: ASF GitHub Bot
            Created on: 05/Oct/22 20:06
            Start Date: 05/Oct/22 20:06
    Worklog Time Spent: 10m 
      Work Description: gtully commented on code in PR #4240:
URL: https://github.com/apache/activemq-artemis/pull/4240#discussion_r985893854


##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java:
##########
@@ -558,6 +564,21 @@ public void physicalSend(Command command) throws 
IOException {
 
    }
 
+   private void chunkSend(final ByteSequence bytes, final int bufferSize, 
final int maxPacketSize) {
+      if (logger.isTraceEnabled()) {
+         logger.trace("Sending a big packet sized as {} with smaller packets 
of {}", bufferSize, maxPacketSize);
+      }
+      for (int posBuffer = 0; posBuffer < bufferSize; posBuffer += 
maxPacketSize) {
+         int chunkSize = Math.min(bufferSize - posBuffer, maxPacketSize);
+         if (logger.isTraceEnabled()) {
+            logger.trace("Sending a partial packet of {} bytes, starting at 
{}", chunkSize, posBuffer);
+         }
+         final ActiveMQBuffer buffer = 
transportConnection.createTransportBuffer(chunkSize);

Review Comment:
   can that one be reused? should always of the right size or smaller



##########
artemis-protocols/artemis-openwire-protocol/src/main/java/org/apache/activemq/artemis/core/protocol/openwire/OpenWireConnection.java:
##########
@@ -558,6 +564,21 @@ public void physicalSend(Command command) throws 
IOException {
 
    }
 
+   private void chunkSend(final ByteSequence bytes, final int bufferSize, 
final int maxPacketSize) {
+      if (logger.isTraceEnabled()) {
+         logger.trace("Sending a big packet sized as {} with smaller packets 
of {}", bufferSize, maxPacketSize);
+      }
+      for (int posBuffer = 0; posBuffer < bufferSize; posBuffer += 
maxPacketSize) {
+         int chunkSize = Math.min(bufferSize - posBuffer, maxPacketSize);
+         if (logger.isTraceEnabled()) {
+            logger.trace("Sending a partial packet of {} bytes, starting at 
{}", chunkSize, posBuffer);
+         }
+         final ActiveMQBuffer buffer = 
transportConnection.createTransportBuffer(chunkSize);

Review Comment:
   can that buffer be reused in the loop? It should always of the right size or 
smaller





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

    Worklog Id:     (was: 814092)
    Time Spent: 0.5h  (was: 20m)

> Avoid excessive NativeMemory allocation when sending OpenWire Multi mega 
> sized messages in openwire
> ---------------------------------------------------------------------------------------------------
>
>                 Key: ARTEMIS-4024
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-4024
>             Project: ActiveMQ Artemis
>          Issue Type: Bug
>            Reporter: Clebert Suconic
>            Assignee: Robbie Gemmell
>            Priority: Major
>             Fix For: 2.27.0
>
>          Time Spent: 0.5h
>  Remaining Estimate: 0h
>
> when sending a large message in openwire, we will read the entire file on the 
> memory, make the conversion from core, and send it on net 
> throughOpenWireProtocolManager::sendPhisical.
> Such allocation should be limited and be sent in chunks.



--
This message was sent by Atlassian Jira
(v8.20.10#820010)

Reply via email to