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

perf: optmize NettyChannelHandlerAdapter with explict extends. #1667

Merged
merged 1 commit into from
Jan 3, 2025

Conversation

He-Pin
Copy link
Member

@He-Pin He-Pin commented Jan 3, 2025

Motivation:
Performance, it was extended to the SimpleChannelInboundHandler which will check if the type is a ByteBuf, now, we just test it explicitly.

Modification:
Make it extends the ChannelInboundHandlerAdapter and release explicitly , which was released by the SimpleChannelInboundHandler

Result:
Simple code and performance a little better.

onMessage(ctx, buf)
} catch {
case ex: Throwable => transformException(ctx, ex)
} finally buf.release() // ByteBuf must be released explicitly
Copy link
Member Author

Choose a reason for hiding this comment

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

it was released by the finally block in SimpleChannelInboundHandler

@He-Pin He-Pin requested review from pjfanning and raboof January 3, 2025 12:58
@He-Pin He-Pin added the performance Related to performance label Jan 3, 2025
Copy link
Member

@raboof raboof left a comment

Choose a reason for hiding this comment

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

the upstream code is at https://github.com/netty/netty/blob/4.1/transport/src/main/java/io/netty/channel/SimpleChannelInboundHandler.java

unrolling the generic code that checks for types dynamically makes some sense

@He-Pin
Copy link
Member Author

He-Pin commented Jan 3, 2025

I ran the cluster test locally and it passed too, we are using this kind of trick at work.

@He-Pin He-Pin merged commit 03712a9 into apache:main Jan 3, 2025
9 checks passed
@He-Pin He-Pin deleted the perf branch January 3, 2025 16:27
@He-Pin
Copy link
Member Author

He-Pin commented Jan 9, 2025

@raboof @pjfanning Do you think we should backport this? as Flink will use this pekko too.

@pjfanning
Copy link
Contributor

I don't want to pre-empt anything. If Flink team want to test the 1.2.0 snapshot and find that works better for them - we could then consider backporting this.

He-Pin added a commit to He-Pin/incubator-pekko that referenced this pull request Jan 10, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
performance Related to performance
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants