[#2684] EpollSocketChannel gathering writes should take fast-path if possible
Motivation: In EpollSocketchannel.writeBytesMultiple(...) we loop over all buffers to see if we need to adjust the readerIndex for incomplete writes. We can skip this if we know that everything was written (a.k.a complete write). Modification: Use fast-path if all bytes are written and so no need to loop over buffers Result: Fast write path for the average use.
This commit is contained in:
parent
e7310cc4c0
commit
028128993d
@ -158,8 +158,12 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
|
||||
}
|
||||
expectedWrittenBytes -= localWrittenBytes;
|
||||
writtenBytes += localWrittenBytes;
|
||||
|
||||
while (offset < end && localWrittenBytes > 0) {
|
||||
if (expectedWrittenBytes == 0) {
|
||||
// Written everything, just break out here (fast-path)
|
||||
done = true;
|
||||
break loop;
|
||||
}
|
||||
do {
|
||||
ByteBuffer buffer = nioBuffers[offset];
|
||||
int pos = buffer.position();
|
||||
int bytes = buffer.limit() - pos;
|
||||
@ -172,12 +176,7 @@ public final class EpollSocketChannel extends AbstractEpollChannel implements So
|
||||
nioBufferCnt--;
|
||||
localWrittenBytes -= bytes;
|
||||
}
|
||||
}
|
||||
|
||||
if (expectedWrittenBytes == 0) {
|
||||
done = true;
|
||||
break;
|
||||
}
|
||||
} while (offset < end && localWrittenBytes > 0);
|
||||
}
|
||||
}
|
||||
updateOutboundBuffer(in, writtenBytes, msgCount, done);
|
||||
|
Loading…
Reference in New Issue
Block a user