Process OP_WRITE before OP_READ to free memory faster
Motivation: We should better first process OP_WRITE before OP_READ as this may allow us to free memory in a faster fashion for previous queued writes. Modifications: Process OP_WRITE before OP_READ Result: Free memory faster for queued writes.
This commit is contained in:
parent
0b939a96cf
commit
3cf7ccbd3c
@ -625,6 +625,12 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
||||
unsafe.finishConnect();
|
||||
}
|
||||
|
||||
// Process OP_WRITE first as we may be able to write some queued buffers and so free memory.
|
||||
if ((readyOps & SelectionKey.OP_WRITE) != 0) {
|
||||
// Call forceFlush which will also take care of clear the OP_WRITE once there is nothing left to write
|
||||
ch.unsafe().forceFlush();
|
||||
}
|
||||
|
||||
// Also check for readOps of 0 to workaround possible JDK bug which may otherwise lead
|
||||
// to a spin loop
|
||||
if ((readyOps & (SelectionKey.OP_READ | SelectionKey.OP_ACCEPT)) != 0 || readyOps == 0) {
|
||||
@ -634,10 +640,6 @@ public final class NioEventLoop extends SingleThreadEventLoop {
|
||||
return;
|
||||
}
|
||||
}
|
||||
if ((readyOps & SelectionKey.OP_WRITE) != 0) {
|
||||
// Call forceFlush which will also take care of clear the OP_WRITE once there is nothing left to write
|
||||
ch.unsafe().forceFlush();
|
||||
}
|
||||
} catch (CancelledKeyException ignored) {
|
||||
unsafe.close(unsafe.voidPromise());
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user