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

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

                Author: ASF GitHub Bot
            Created on: 31/Aug/21 15:29
            Start Date: 31/Aug/21 15:29
    Worklog Time Spent: 10m 
      Work Description: gemmellr commented on pull request #3711:
URL: https://github.com/apache/activemq-artemis/pull/3711#issuecomment-909320906


   > In the current PR I see that I'm relying (write side) on the knowledge 
that incoming data is using a composite readable buffer, while the whole 
complete version should account of Netty/NIO ones too, to save the copy to 
happen, looking more as
   > 
   > ```java
   >    public void addBytes(ReadableBuffer data) throws Exception {
   >       parseLargeMessage(data);
   >       boolean releaseBuffer = true;
   >       ByteBuf writeBuffer = null;
   >       try {
   >          if (!data.hasArray()) {
   >             // try access some direct buffer in
   >             if (data instanceof ReadableBuffer.ByteBufferReader) {
   >                final ByteBuffer nioBuffer = data.byteBuffer();
   >                if (nioBuffer.isDirect()) {
   >                   writeBuffer = Unpooled.wrappedBuffer(nioBuffer);
   >                   releaseBuffer = false;
   >                }
   >             } else if (data instanceof NettyReadable) {
   >                final ByteBuf nettyBuffer = ((NettyReadable) 
data).getByteBuf();
   >                if (nettyBuffer.isDirect()) {
   >                   writeBuffer = nettyBuffer;
   >                   releaseBuffer = false;
   >                }
   >             }
   >          }
   >          if (writeBuffer == null) {
   >             // perform copy of data
   >             final int bytes = data.remaining();
   >             writeBuffer = 
PooledByteBufAllocator.DEFAULT.directBuffer(bytes, bytes);
   >             data.get(new NettyWritable(writeBuffer));
   >          }
   >          largeBody.addBytes(new ChannelBufferWrapper(writeBuffer, true, 
true));
   >       } finally {
   >          if (releaseBuffer) {
   >             if (writeBuffer != null) {
   >                writeBuffer.release();
   >             }
   >          }
   >       }
   >    }
   > ```
   > 
   > It seems very complicate to me, so I prefer to leave it as it is, 
@gemmellr wdyt?
   > 
   
   Im a bit confused by the above bits of the comment. I'm not seeing where you 
actually rely on the knowledge that incoming data is using a CRB (which it 
currently is, but that could change at any time..it didnt used to for example). 
In any case I would agree its complicated enough without adding all the above.
   
   > While I need your advice on the small change I've made on 
[7f56ab8](https://github.com/apache/activemq-artemis/commit/7f56ab813f8eb1e5ceb7dba4d214ee6507d9f386):
 is it safe?
   
   I dont really know what the original is really doing or how this updates it, 
so...dont know yet, need to look further.


-- 
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: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]


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

    Worklog Id:     (was: 644483)
    Time Spent: 6h 10m  (was: 6h)

> 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: 6h 10m
>  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