tabish121 commented on code in PR #5950:
URL: https://github.com/apache/activemq-artemis/pull/5950#discussion_r2401992210
##########
artemis-protocols/artemis-amqp-protocol/src/main/java/org/apache/activemq/artemis/protocol/amqp/proton/AMQPTunneledCoreLargeMessageWriter.java:
##########
@@ -219,15 +219,14 @@ private boolean trySendDeliveryAnnotations(ByteBuf
frameBuffer, NettyReadable fr
for (; protonSender.getLocalState() != EndpointState.CLOSED && state ==
State.STREAMING_DELIVERY_ANNOTATIONS; ) {
if (annotations != null && annotations.getValue() != null &&
!annotations.getValue().isEmpty()) {
if (!connection.flowControl(this::resume)) {
- break; // Resume will restart writing the headers section from
where we left off.
+ break; // Resume will restart writing the delivery annotations
section from where we left off.
}
final ByteBuf annotationsBuffer =
getOrCreateDeliveryAnnotationsBuffer();
- final int readSize = (int) Math.min(frameBuffer.writableBytes(),
annotationsBuffer.readableBytes() - position);
+ final int readSize = Math.min(frameBuffer.writableBytes(),
annotationsBuffer.readableBytes());
- position += readSize;
-
- annotationsBuffer.readBytes(frameBuffer, readSize);
+
annotationsBuffer.readBytes(frameBuffer.internalNioBuffer(frameBuffer.writerIndex(),
readSize));
+ frameBuffer.writerIndex(frameBuffer.writerIndex() + readSize);
Review Comment:
It is effectively bypassing some of the onion peeling that happens in the
netty buffer when doing the readBytes. By leveraging the fact that we've
allocated a fixed buffer which we control and knowing that we are safely within
the boundaries we can leverage the internal NIO buffer to walk the path of an
almost immediate bulk copy of bytes instead of peeling away the layers via
readBytes and checking repeated for bounds and capacity there is a slight
performance optimization.
This isn't necessary here for this fix but it does further align the logic
used in the three states of writing the tunneled core message bytes which I
felt was reasonable as it makes them all more consistent in their operation.
--
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]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]
For further information, visit: https://activemq.apache.org/contact