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

Optimize DefaultChannelPipeline in terms of memory usage and initializat... #2546

Closed
wants to merge 1 commit into from

Conversation

normanmaurer
Copy link
Member

...ion time

Motivation:
Each of DefaultChannelPipeline instance creates an head and tail that wraps a handler. These are used to chain together other DefaultChannelHandlerContext that are created once a new ChannelHandler is added. There are a few things here that can be improved in terms of memory usage and initialization time.

Modification:

  • Only generate the name for the tail and head one time as it will never change anyway
  • Only compute the skipFlags for the tail and head one time as it will never change
  • Rename DefaultChannelHandlerContext to AbstractChannelHandlerContext and make it abstract
  • Create a new DefaultChannelHandlerContext that is used when a ChannelHandler is added to the DefaultChannelPipeline
  • Rename TailHandler to TailContext and HeadHandler to HeadContext and let them extend AbstractChannelHandlerContext. This way we can save 2 object creations per DefaultChannelPipeline

Result:

  • Less memory usage because we have 2 less objects per DefaultChannelPipeline
  • Faster creation of DefaultChannelPipeline as we not need to compute the skipFlags and not need to generate the name for the head and tail

…zation time

Motivation:
Each of DefaultChannelPipeline instance creates an head and tail that wraps a handler. These are used to chain together other DefaultChannelHandlerContext that are created once a new ChannelHandler is added. There are a few things here that can be improved in terms of memory usage and initialization time.

Modification:
- Only generate the name for the tail and head one time as it will never change anyway
- Only compute the skipFlags for the tail and head one time as it will never change
- Rename DefaultChannelHandlerContext to AbstractChannelHandlerContext and make it abstract
- Create a new DefaultChannelHandlerContext that is used when a ChannelHandler is added to the DefaultChannelPipeline
- Rename TailHandler to TailContext and HeadHandler to HeadContext and let them extend AbstractChannelHandlerContext. This way we can save 2 object creations per DefaultChannelPipeline

Result:
- Less memory usage because we have 2 less objects per DefaultChannelPipeline
- Faster creation of DefaultChannelPipeline as we not need to compute the skipFlags and not need to generate the name for the head and tail
@normanmaurer
Copy link
Member Author

@trustin please review!

@ghost
Copy link

ghost commented Jun 7, 2014

Build result for #2546 at 600dbac: Success

@normanmaurer
Copy link
Member Author

@trustin I also would like to port this to 4.1 and 4.0 if you agree it is a good idea :)

@trustin
Copy link
Member

trustin commented Jun 10, 2014

Looks good to me. Yeah, we should merge this into 4.0/4.1/master

@normanmaurer
Copy link
Member Author

@trustin thanks for review... merged into 4.0, 4.1 and master

@normanmaurer normanmaurer added this to the 4.0.20.Final milestone Jun 10, 2014
@normanmaurer normanmaurer deleted the optimize_defaultchannelpipeline branch June 11, 2014 05:10
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

2 participants