-
Notifications
You must be signed in to change notification settings - Fork 26.6k
Optimize NettyBackedChannelBuffer for direct buffer transfer #16027
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
base: 3.3
Are you sure you want to change the base?
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## 3.3 #16027 +/- ##
============================================
+ Coverage 60.74% 60.75% +0.01%
+ Complexity 11754 11750 -4
============================================
Files 1949 1949
Lines 88898 88914 +16
Branches 13407 13409 +2
============================================
+ Hits 53998 54018 +20
- Misses 29337 29340 +3
+ Partials 5563 5556 -7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
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.
Pull request overview
This PR optimizes buffer transfer operations in NettyBackedChannelBuffer by eliminating intermediate byte array copies when both source and destination are NettyBackedChannelBuffer instances. The changes leverage Netty's native ByteBuf transfer capabilities for direct buffer-to-buffer transfers while maintaining backward compatibility through a fallback path for other ChannelBuffer implementations.
Changes:
- Optimize
getBytes,setBytes,readBytes, andwriteBytesmethods to use direct Netty ByteBuf transfers when possible - Add type checking to detect NettyBackedChannelBuffer instances and use optimized path
- Maintain fallback to intermediate byte array copy for other ChannelBuffer implementations
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...etty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java
Show resolved
Hide resolved
...etty4/src/main/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBuffer.java
Show resolved
Hide resolved
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.
Pull request overview
Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
...4/src/test/java/org/apache/dubbo/remoting/transport/netty4/NettyBackedChannelBufferTest.java
Outdated
Show resolved
Hide resolved
EarthChen
left a comment
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.
LGTM
- Optimize getBytes/setBytes/readBytes/writeBytes methods - Avoid intermediate byte array copy when source/destination is NettyBackedChannelBuffer - Directly use Netty's ByteBuf transfer capabilities - Add fallback to intermediate array copy for other ChannelBuffer implementations - Improve performance by 4-5x for Netty-to-Netty buffer transfers
…dubbo/remoting/transport/netty4/NettyBackedChannelBufferTest.java Co-authored-by: Copilot <175728472+Copilot@users.noreply.github.com>
2da618a to
0a7a9ef
Compare
Below are test code:
Test output: