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
Redo fix scalability issue due to checkcast on context's invoke operations #13741
Redo fix scalability issue due to checkcast on context's invoke operations #13741
Conversation
…tions Motivation: ChannelDuplexHandler can implements both ChannelOutboundHandler and ChannelInboundHandler causing a scalability issue due to checkcast due to https://bugs.openjdk.org/browse/JDK-8180450 Not only: there are different classes eg Http2ConnectionHandler, which implement them transitively, by using one of the 2 existing adapters (ChannelInboundAdapter, ChanneOutboundAdapters). The existing change at netty#12806 was fixing only the duplex cases, but others like the above one was still affected. Modifications: Replace the duplex type checks with broader inbound adapter ones, given that duplex is still based on it. Add outbound adapters type checks in addition to duplex ones. Result: More scalable adapters-based channel handler operations.
@@ -653,6 +655,8 @@ | |||
headContext.connect(this, remoteAddress, localAddress, promise); | |||
} else if (handler instanceof ChannelDuplexHandler) { | |||
((ChannelDuplexHandler) handler).connect(this, remoteAddress, localAddress, promise); | |||
} else if (handler instanceof ChannelOutboundHandlerAdapter) { | |||
((ChannelOutboundHandlerAdapter) handler).connect(this, remoteAddress, localAddress, promise); |
Check failure
Code scanning / CodeQL
Server-side request forgery Critical
user-provided value
Potential server-side request forgery due to a
user-provided value
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.
CodeQL go home...you're drunk :"(
This mitigate eclipse-vertx/vert.x#5039 and help any case where we have adapters which implement the missing out/in handler. ATM the other solutions doesn't look any better:
ChannelOutBoundHandler asChannelOutbound() {
return this
}
ChannelOutBoundHandler asChannelOutbound() {
return null
} which could be used within Netty's as a single And obviously, the other solution is the one I've made here :/ |
Sorry that i didn't make it the first time like this @normanmaurer but after one year (or more) fixing these around in different libraries we've learnt different ways to improve the solutions, which are still ugly, at best |
@franz1981 no worries… Thanks for the work! |
@franz1981 do you have any numbers for before and after ? |
@normanmaurer I'm running other checks with some nightly run, mostly to be sure no regressions due to the additional type checks, TBH, but the first tests reported the usual ~15%-60% performance increase (is not as bad as the http one) based on the number of cores. I know it sounds wow, but is really a bug, which shouldn't surprise. I can modify the existing |
sounds good |
Based on some nightly run, I see no regressions, meaning that, if it works, it works great (fixing the scalability issue, hence delivering staggering improvements for CPU bound scenarios with many cores), if it doesn't, no harm. |
Motivation:
ChannelDuplexHandler can implements both ChannelOutboundHandler and ChannelInboundHandler causing a scalability issue due to checkcast due to https://bugs.openjdk.org/browse/JDK-8180450
Not only: there are different classes eg Http2ConnectionHandler, which implement them transitively, by using one of the 2 existing adapters (ChannelInboundAdapter, ChanneOutboundAdapters). The existing change at #12806 was fixing only the duplex cases, but others like the above one was still affected.
Modifications:
Replace the duplex type checks with broader inbound adapter ones, given that duplex is still based on it. Add outbound adapters type checks in addition to duplex ones.
Result:
More scalable adapters-based channel handler operations.