-
Notifications
You must be signed in to change notification settings - Fork 26.5k
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
Heartbeat skip serialize and deserialize #7077
Heartbeat skip serialize and deserialize #7077
Conversation
Codecov Report
@@ Coverage Diff @@
## master #7077 +/- ##
============================================
+ Coverage 59.22% 59.61% +0.38%
+ Complexity 508 288 -220
============================================
Files 1028 1001 -27
Lines 41525 39994 -1531
Branches 6038 5941 -97
============================================
- Hits 24593 23841 -752
+ Misses 14169 13440 -729
+ Partials 2763 2713 -50 Continue to review full report at Codecov.
|
...oting/dubbo-remoting-api/src/main/java/org/apache/dubbo/remoting/transport/CodecSupport.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.
LGTM.
What is the purpose of the change
提供者和消费者之间的心跳,Request和Response的Data都为null:
当提供者和消费者数量非常大时,每个节点都需要发送/接受大量的心跳Requet和Response,这些Requet、Response也会和服务调用一样经过serialize+encode、decode+deserialize,而其中的serialize/deserialize需要消耗过多的CPU资源。
这个优化的目的是对于心跳Requet/Response跳过serialize/deserialize处理,serialize改为赋值为null对象的序列化后字节,deserialize改为直接赋值null。
Brief changelog
在CodecSupport中增加getNullBytesOf(Serialization s)方法,首次访问时根据serialization获得null对象的字节数组并缓存到ID_NULLBYTES_MAP
DubboCodec、ExchangeCodec中在调整encodeRequest、encodeResponse、decodeBody逻辑,实现上述目标。
备注:目前DUBBO的Serialization的实现中,以下三个实现其实尚不支持null对象的序列化,在CodecSupport.getNullBytesOf中降级为返回空字符串。
Follow this checklist to help us incorporate your contribution quickly and easily:
[Dubbo-XXX] Fix UnknownException when host config not exist #XXX
. Each commit in the pull request should have a meaningful subject line and body.mvn clean install -DskipTests=false
&mvn clean test-compile failsafe:integration-test
to make sure unit-test and integration-test pass.