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

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

                Author: ASF GitHub Bot
            Created on: 03/Sep/21 12:01
            Start Date: 03/Sep/21 12:01
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on a change in pull request #3711:
URL: https://github.com/apache/activemq-artemis/pull/3711#discussion_r701834819



##########
File path: 
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/ProtonServerSenderContext.java
##########
@@ -584,56 +583,45 @@ void deliver() {
             deliveryAnnotationsToEncode = null;
          }
 
-         LargeBodyReader context = message.getLargeBodyReader();
          try {
-            context.open();
-            try {
+            final ByteBuf frameBuffer = 
PooledByteBufAllocator.DEFAULT.directBuffer(frameSize, frameSize);
+            final NettyReadable frameView = new NettyReadable(frameBuffer);
+            try (LargeBodyReader context = message.getLargeBodyReader()) {
+               context.open();
                context.position(position);
                long bodySize = context.getSize();
+               // materialize it so we can use its internal NIO buffer
+               frameBuffer.ensureWritable(frameSize);
 
-               ByteBuffer buf = ByteBuffer.allocate(frameSize);
+               if (position == 0 && sender.getLocalState() != 
EndpointState.CLOSED && position < bodySize) {

Review comment:
       
   > > e.g there are no delivery-annotations or header in the original message 
to skip past, or the subsequently generated ones precisely fit in the buffer 
with room for nothing else, or the connection was flow controlled before 
sending anything else
   > 
   > If there are no delivery annotations or header, the deliveryInitialPacket 
takes care filling the rest of the frame with some file content (and that 
should be at least one byte, but this is a missing check yet, indeed), 
increasing position over 0.
   
   True, forgot that.
   
   > If flow control kick in, it would happen before doing it, hence only close 
or available Netty outbound buffer would resume it (with position still == 0).
   > Assuming that files contains at least a single byte, using position == 0 
should be safe, logically, despite not very intuitive.
   
   I meant flow control after sending the initial packet, in the loop. There 
are 2 routes that it is possible (but unlikely, I admit) to get into the loop 
without incrementing the position field, which would mean it could go through 
the initial stuff again and generate the initial packet again if it flow 
controls.
   
   




-- 
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.

To unsubscribe, e-mail: gitbox-unsubscr...@activemq.apache.org

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


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

    Worklog Id:     (was: 646270)
    Time Spent: 9h 40m  (was: 9.5h)

> Speedup AMQP large message streaming
> ------------------------------------
>
>                 Key: ARTEMIS-3449
>                 URL: https://issues.apache.org/jira/browse/ARTEMIS-3449
>             Project: ActiveMQ Artemis
>          Issue Type: Improvement
>            Reporter: Francesco Nigro
>            Assignee: Francesco Nigro
>            Priority: Major
>          Time Spent: 9h 40m
>  Remaining Estimate: 0h
>
> AMQP is using unpooled heap ByteBuffer(s) to stream AMQP large messages: 
> given that the underline NIO sequential file can both use FileChannel or 
> RandomAccessFile (depending if the ByteBuffer used is direct/heap based), 
> both approaches would benefit from using Netty pooled direct buffers and save 
> additional copies (performed by RandomAccessFile) to happen, reducing GC too.



--
This message was sent by Atlassian Jira
(v8.3.4#803005)

Reply via email to