[
https://issues.apache.org/jira/browse/ARTEMIS-2239?focusedWorklogId=190026&page=com.atlassian.jira.plugin.system.issuetabpanels:worklog-tabpanel#worklog-190026
]
ASF GitHub Bot logged work on ARTEMIS-2239:
-------------------------------------------
Author: ASF GitHub Bot
Created on: 25/Jan/19 14:39
Start Date: 25/Jan/19 14:39
Worklog Time Spent: 10m
Work Description: clebertsuconic commented on pull request #2522:
ARTEMIS-2239 Zero-copy NIO/MAPPED TimedBuffer
URL: https://github.com/apache/activemq-artemis/pull/2522#discussion_r251006945
##########
File path:
artemis-journal/src/main/java/org/apache/activemq/artemis/core/io/buffer/TimedBuffer.java
##########
@@ -358,13 +358,7 @@ public boolean flushBatch() {
bytesFlushed.addAndGet(pos);
}
- final ByteBuffer bufferToFlush =
bufferObserver.newBuffer(bufferSize, pos);
- //bufferObserver::newBuffer doesn't necessary return a buffer
with limit == pos or limit == bufferSize!!
- bufferToFlush.limit(pos);
- //perform memcpy under the hood due to the off heap buffer
- buffer.getBytes(0, bufferToFlush);
-
- bufferObserver.flushBuffer(bufferToFlush, pendingSync,
callbacks);
+ bufferObserver.flushBuffer(buffer.byteBuf(), pendingSync,
callbacks);
Review comment:
I wish it was that simple.
that's only viable if your write operation is synchronous.
That's probably ok with NIO or Mapped, but it's definitely not ok with
libaio.
If you allow the inner buffer to be reused like that, TimedBuffer will be
making changes to a buffer that's been submitted to the kernel, and you may
endup with wrong data.
And that kind of race is hard to catch.
You can only that do this kind of thing on NIO or Mapped, assuming their
buffers will be copied to the file right away.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
[email protected]
Issue Time Tracking
-------------------
Worklog Id: (was: 190026)
Time Spent: 20m (was: 10m)
> Zero-copy NIO/MAPPED TimedBuffer
> --------------------------------
>
> Key: ARTEMIS-2239
> URL: https://issues.apache.org/jira/browse/ARTEMIS-2239
> Project: ActiveMQ Artemis
> Issue Type: Improvement
> Components: Broker
> Affects Versions: 2.6.4
> Reporter: Francesco Nigro
> Assignee: Francesco Nigro
> Priority: Major
> Time Spent: 20m
> Remaining Estimate: 0h
>
> NIO/MAPPED journal types are currently performing the copy of the buffer used
> on TimedBuffer to accumulate writes, but this copy (and the zeroing of the
> new buffer) could be avoided, reducing dramatically the CPU usage and
> latencies during a burst of writes.
> An added benefit of this change is that isn't necessary anymore to stress the
> thread pool of the file factory, because there is no need to pool the buffer
> used to perform the write.
--
This message was sent by Atlassian JIRA
(v7.6.3#76005)