Skip to content
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

Closed
wants to merge 5 commits into from
Closed

Use Netty MessageToMessage Encoder/Decoder #1034

wants to merge 5 commits into from

Conversation

no2chem
Copy link
Member

@no2chem no2chem commented Dec 4, 2017

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):

  • There are no TODOs left in the code
  • Coding conventions (e.g. for logging, unit tests) have been followed
  • Change is covered by automated tests
  • Public API has Javadoc

@no2chem no2chem added this to the 0.2.0 milestone Dec 4, 2017
@no2chem no2chem self-assigned this Dec 4, 2017
@coveralls
Copy link

Coverage Status

Coverage decreased (-0.003%) to 70.599% when pulling d7387d9 on MsgToMsgM into cbb2c2a on master.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.007%) to 70.609% when pulling 89877f4 on MsgToMsgM into cbb2c2a on master.

@corfudb-performance
Copy link
Collaborator

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
*** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 5 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 10 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 1 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 5 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 10 threads, Disk mode

An interactive dashboard with Pull Request Performance Metrics for ALL cluster types and numbers of threads in run, is available at:
Pull Request #1034 Graphs

import lombok.extern.slf4j.Slf4j;


/**
* Created by mwei on 10/1/15.
*/
@Slf4j
public class NettyCorfuMessageDecoder extends ByteToMessageDecoder {
@Sharable
Copy link
Collaborator

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

Copy link
Member Author

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.

Copy link
Collaborator

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.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 70.706% when pulling 1fbb7bc on MsgToMsgM into cbb2c2a on master.

@corfudb-performance
Copy link
Collaborator

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
*** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 5 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 10 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 1 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 5 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 10 threads, Disk mode

An interactive dashboard with Pull Request Performance Metrics for ALL cluster types and numbers of threads in run, is available at:
Pull Request #1034 Graphs

@annym
Copy link
Collaborator

annym commented Dec 7, 2017

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

@no2chem
Copy link
Member Author

no2chem commented Dec 7, 2017

@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;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.netty.buffer.Unpooled'. rule

@@ -2,36 +2,34 @@

import io.netty.buffer.ByteBuf;
import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandler.Sharable;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.netty.channel.ChannelHandler.Sharable'. rule

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.netty.channel.ChannelInboundHandler'. rule

import io.netty.channel.ChannelHandlerContext;
import io.netty.channel.ChannelInboundHandler;
import io.netty.handler.codec.ByteToMessageDecoder;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.netty.handler.codec.ByteToMessageDecoder'. rule

import io.netty.handler.codec.ByteToMessageDecoder;

import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.MessageToMessageDecoder;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'io.netty.handler.codec.MessageToMessageDecoder'. rule

import io.netty.handler.codec.ByteToMessageDecoder;

import io.netty.handler.codec.LengthFieldBasedFrameDecoder;
import io.netty.handler.codec.MessageToMessageDecoder;
import java.util.List;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'java.util.List'. rule

import java.util.List;

import javax.annotation.Nonnull;
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

MINOR Remove this unused import 'javax.annotation.Nonnull'. rule

@corfu-repo
Copy link
Collaborator

SonarQube analysis reported 9 issues

  • MINOR 9 minor

Watch the comments in this conversation to review them.

2 extra issues

Note: 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:

  1. MINOR CorfuServer.java#L46: Remove this unused import 'org.corfudb.security.tls.TlsUtils'. rule
  2. MINOR NettyClientRouter.java#L53: Remove this unused import 'org.corfudb.security.tls.TlsUtils'. rule

@coveralls
Copy link

Coverage Status

Coverage increased (+0.1%) to 70.722% when pulling b822f38 on MsgToMsgM into cbb2c2a on master.

@corfudb-performance
Copy link
Collaborator

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
*** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 5 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx+Scan workload, 10 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 1 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 5 threads, Disk mode
*** 0.0% transaction FAILURE rate for NonConflictingTx workload, 10 threads, Disk mode

An interactive dashboard with Pull Request Performance Metrics for ALL cluster types and numbers of threads in run, is available at:
Pull Request #1034 Graphs

@Rtremblay Rtremblay removed this from the 0.2.0 milestone Dec 20, 2017
@Rtremblay Rtremblay added this to the 0.4.0 milestone Dec 20, 2017
@no2chem no2chem closed this Jun 18, 2018
@Maithem Maithem deleted the MsgToMsgM branch July 29, 2019 16:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

6 participants