From d56f403c69d38683294b2d090f10b971b4888ff9 Mon Sep 17 00:00:00 2001 From: Norman Maurer Date: Fri, 28 Jul 2017 12:18:44 +0200 Subject: [PATCH] First call channelReadComplete(...) before flush(...) for better performance Motivation: In Http2ConnectionHandler we call flush(...) in channelReadComplete(...) to ensure we update the flow-controller and write stuff to the remote peer. We should better flip the order and so may be able to pick up more bytes. Modifications: Change order of calls. Result: Better performance --- .../io/netty/handler/codec/http2/Http2ConnectionHandler.java | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java index b450fa93cf..c85ecd170f 100644 --- a/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java +++ b/codec-http2/src/main/java/io/netty/handler/codec/http2/Http2ConnectionHandler.java @@ -484,9 +484,10 @@ public class Http2ConnectionHandler extends ByteToMessageDecoder implements Http // Trigger flush after read on the assumption that flush is cheap if there is nothing to write and that // for flow-control the read may release window that causes data to be written that can now be flushed. try { - flush(ctx); - } finally { + // First call channelReadComplete(...) as this may produce more data that we want to flush super.channelReadComplete(ctx); + } finally { + flush(ctx); } }