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/08/31 15:29:42 UTC
[GitHub] [activemq-artemis] gemmellr commented on pull request #3711: ARTEMIS-3449 Speedup AMQP large message streaming
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: gitbox-unsubscribe@activemq.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org