[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:
huangli
2021-12-27 20:02:57 +08:00
committed by GitHub
parent 75557b8700
commit 6d247cb3c6
@@ -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);
}