[
https://issues.apache.org/jira/browse/ARTEMIS-3449?focusedWorklogId=645963&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-645963
]
ASF GitHub Bot logged work on ARTEMIS-3449:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 02/Sep/21 17:59
Start Date: 02/Sep/21 17:59
Worklog Time Spent: 10m
Work Description: franz1981 commented on a change in pull request #3711:
URL: https://github.com/apache/activemq-artemis/pull/3711#discussion_r701307685
##########
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:
> "position = 0..." is a pretty awkward way of saying 'have we finished
doing the required initial packet work before'. Adding a specific boolean for
this might be better
Agree but I understand why @clebertsuconic used position here, to save
adding another field member (ie another state variable to preserve/maintain) to
track something that position validation could track (more on this later).
> Also it doesnt necessarily actually matter if position <bodySize()
Good point, this is not a useful check there
> 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.
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.
--
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: 645963)
Time Spent: 9h 10m (was: 9h)
> 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 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)