mirror of
https://github.com/apache/rocketmq.git
synced 2026-09-24 16:04:00 +08:00
[ISSUE 3585] [Part J] Use MappedByteBuffer instead of FileChannel to write consume queue and slave commitlog. (#3657)
This commit improve reput performance and speed up consume qps greatly. In our test, produce about 200,000 tps. 72 queue consume qps: from about 70,000 to 200,000 600 queue consume qps: from about 70,000 to 110,000
This commit is contained in:
@@ -236,8 +236,9 @@ public class MappedFile extends ReferenceResource {
|
||||
|
||||
if ((currentPos + data.length) <= this.fileSize) {
|
||||
try {
|
||||
this.fileChannel.position(currentPos);
|
||||
this.fileChannel.write(ByteBuffer.wrap(data));
|
||||
ByteBuffer buf = this.mappedByteBuffer.slice();
|
||||
buf.position(currentPos);
|
||||
buf.put(data);
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred when append message to mappedFile.", e);
|
||||
}
|
||||
@@ -259,8 +260,9 @@ public class MappedFile extends ReferenceResource {
|
||||
|
||||
if ((currentPos + length) <= this.fileSize) {
|
||||
try {
|
||||
this.fileChannel.position(currentPos);
|
||||
this.fileChannel.write(ByteBuffer.wrap(data, offset, length));
|
||||
ByteBuffer buf = this.mappedByteBuffer.slice();
|
||||
buf.position(currentPos);
|
||||
buf.put(data, offset, length);
|
||||
} catch (Throwable e) {
|
||||
log.error("Error occurred when append message to mappedFile.", e);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user