[ 
https://issues.apache.org/jira/browse/FLINK-8768?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=16378527#comment-16378527
 ] 

ASF GitHub Bot commented on FLINK-8768:
---------------------------------------

Github user pnowojski commented on a diff in the pull request:

    https://github.com/apache/flink/pull/5570#discussion_r170911325
  
    --- Diff: 
flink-runtime/src/main/java/org/apache/flink/runtime/io/network/netty/NettyMessage.java
 ---
    @@ -188,58 +186,83 @@ public void write(ChannelHandlerContext ctx, Object 
msg, ChannelPromise promise)
                                ctx.write(msg, promise);
                        }
                }
    -
    -           // Create the frame length decoder here as it depends on the 
encoder
    -           //
    -           // 
+------------------+------------------+--------++----------------+
    -           // | FRAME LENGTH (4) | MAGIC NUMBER (4) | ID (1) || CUSTOM 
MESSAGE |
    -           // 
+------------------+------------------+--------++----------------+
    -           static LengthFieldBasedFrameDecoder createFrameLengthDecoder() {
    -                   return new 
LengthFieldBasedFrameDecoder(Integer.MAX_VALUE, 0, 4, -4, 4);
    -           }
        }
     
    -   @ChannelHandler.Sharable
    -   static class NettyMessageDecoder extends 
MessageToMessageDecoder<ByteBuf> {
    +   /**
    +    * Message decoder based on netty's {@link 
LengthFieldBasedFrameDecoder} but avoiding the
    +    * additional memory copy inside {@link 
#extractFrame(ChannelHandlerContext, ByteBuf, int, int)}
    +    * since we completely decode the {@link ByteBuf} inside {@link 
#decode(ChannelHandlerContext,
    +    * ByteBuf)} and will not re-use it afterwards.
    +    *
    +    * <p>The frame-length encoder will be based on this transmission 
scheme created by {@link NettyMessage#allocateBuffer(ByteBufAllocator, byte, 
int)}:
    +    * <pre>
    +    * +------------------+------------------+--------++----------------+
    +    * | FRAME LENGTH (4) | MAGIC NUMBER (4) | ID (1) || CUSTOM MESSAGE |
    +    * +------------------+------------------+--------++----------------+
    +    * </pre>
    +    */
    +   static class NettyMessageDecoder extends LengthFieldBasedFrameDecoder {
    +           private final boolean restoreOldNettyBehaviour;
    --- End diff --
    
    drop the unused field?


> Change NettyMessageDecoder to inherit from LengthFieldBasedFrameDecoder
> -----------------------------------------------------------------------
>
>                 Key: FLINK-8768
>                 URL: https://issues.apache.org/jira/browse/FLINK-8768
>             Project: Flink
>          Issue Type: Improvement
>          Components: Network
>            Reporter: Nico Kruber
>            Assignee: Nico Kruber
>            Priority: Major
>             Fix For: 1.5.0
>
>
> Let {{NettyMessageDecoder}} inherit from {{LengthFieldBasedFrameDecoder}} 
> instead of being an additional step in the pipeline. This does not only 
> remove overhead in the pipeline itself but also allows use to override the 
> {{#extractFrame()}} method to restore the old Netty 4.0.27 behaviour for 
> non-credit based code paths which had a bug with Netty >= 4.0.28 there.



--
This message was sent by Atlassian JIRA
(v7.6.3#76005)

Reply via email to