-
Notifications
You must be signed in to change notification settings - Fork 121
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Use Netty MessageToMessage Encoder/Decoder #1034
Conversation
Results automatically generated by CorfuDB Benchmark Framework to assess the performance of this pull request for commit 89877f4. *** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 1 threads, Disk mode An interactive dashboard with Pull Request Performance Metrics for ALL cluster types and numbers of threads in run, is available at: |
import lombok.extern.slf4j.Slf4j; | ||
|
||
|
||
/** | ||
* Created by mwei on 10/1/15. | ||
*/ | ||
@Slf4j | ||
public class NettyCorfuMessageDecoder extends ByteToMessageDecoder { | ||
@Sharable |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe It is not actually enough just to annotate it as 'sharable' (this is only an informational annotation). This would require CorfuServer and NettyClientRouter to add the same instance to the pipeline. Maybe this can explain why we don't actually see improvements in the performance runs.
In the Documentation of the annotation you can find this description:
This annotation is provided for documentation purpose, just like the JCIP annotations.
For more details you can read the "Shared and Exclusive Channel Handlers" of this blog
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@annym Thanks! I made the change to keep the same encoder/decoder. I wouldn't expect a really significant performance increase until we start using multiple channels.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great! You are right we would see improvements only when using multiple channels.
Results automatically generated by CorfuDB Benchmark Framework to assess the performance of this pull request for commit 1fbb7bc. *** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 1 threads, Disk mode An interactive dashboard with Pull Request Performance Metrics for ALL cluster types and numbers of threads in run, is available at: |
Can you please explain what you mean with "Since our messages are framed by the LengthField encoder/decoder"? Not sure I understand what this means. Because if so, shouldn't we extend from LengthFieldBasedFrameDecoder |
@annym Great point, not sure why it wasn't like this to begin with. I updated the decoder to extend from LengthFieldBasedFrameDecoder per your suggestions. I'll get to modifying the encoder next. Unfortunately they can no longer be sharable (since the LengthFieldBasedFrameDecoder holds state), but I think having the pipeline shorter is much better! |
@@ -2,36 +2,34 @@ | |||
|
|||
import io.netty.buffer.ByteBuf; | |||
import io.netty.buffer.Unpooled; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@@ -2,36 +2,34 @@ | |||
|
|||
import io.netty.buffer.ByteBuf; | |||
import io.netty.buffer.Unpooled; | |||
import io.netty.channel.ChannelHandler.Sharable; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.ChannelInboundHandler; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import io.netty.channel.ChannelHandlerContext; | ||
import io.netty.channel.ChannelInboundHandler; | ||
import io.netty.handler.codec.ByteToMessageDecoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import io.netty.handler.codec.ByteToMessageDecoder; | ||
|
||
import io.netty.handler.codec.LengthFieldBasedFrameDecoder; | ||
import io.netty.handler.codec.MessageToMessageDecoder; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import io.netty.handler.codec.ByteToMessageDecoder; | ||
|
||
import io.netty.handler.codec.LengthFieldBasedFrameDecoder; | ||
import io.netty.handler.codec.MessageToMessageDecoder; | ||
import java.util.List; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
import java.util.List; | ||
|
||
import javax.annotation.Nonnull; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SonarQube analysis reported 9 issues Watch the comments in this conversation to review them. 2 extra issuesNote: The following issues were found on lines that were not modified in the pull request. Because these issues can't be reported as line comments, they are summarized here:
|
Results automatically generated by CorfuDB Benchmark Framework to assess the performance of this pull request for commit b822f38. *** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 1 threads, Disk mode An interactive dashboard with Pull Request Performance Metrics for ALL cluster types and numbers of threads in run, is available at: |
Overview
Description: Previously, Netty MessageToByte and ByteToMessage encoders/decoders were used to encode/decode Corfu messages. Since our messages are framed by the LengthField encoder/decoder, there is no need for extra state logic to determine how many messages there are, and this enables these channels to be implemented as sharable, which should reduce overhead in the Netty pipeline.
Why should this be merged: Relatively simple and low risk change to the Netty pipeline which should reduce overhead and slightly improve performance.
Checklist (Definition of Done):