coderzc commented on code in PR #15678:
URL: https://github.com/apache/pulsar/pull/15678#discussion_r887814054
##########
pulsar-proxy/src/main/java/org/apache/pulsar/proxy/server/ProxyConnection.java:
##########
@@ -259,6 +271,33 @@ public void channelRead(final ChannelHandlerContext ctx,
Object msg) throws Exce
}
}
+ /**
+ * Use splice to zero-copy of NIC to NIC.
+ * @param inboundChannel input channel
+ * @param outboundChannel output channel
+ */
+ protected void spliceNIC2NIC(EpollSocketChannel inboundChannel,
EpollSocketChannel outboundChannel) {
+ inboundChannel.config().setAutoRead(false);
+
+ ChannelPromise promise = ctx.newPromise();
+ inboundChannel.spliceTo(outboundChannel, SPLICE_BYTES, promise);
+ promise.addListener((ChannelFutureListener) future -> {
+ if (!future.isSuccess()) {
+
future.channel().pipeline().fireExceptionCaught(future.cause());
+ } else {
+ ProxyService.OPS_COUNTER.inc();
+
directProxyHandler.getInboundChannelRequestsRate().recordEvent(SPLICE_BYTES);
+ ProxyService.BYTES_COUNTER.inc(SPLICE_BYTES);
+ }
+ });
+
+ inboundChannel.config().setAutoRead(true);
Review Comment:
Thanks, I remove the settings of `autoRead`.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]