Skip to content

Conversation

@lifepuzzlefun
Copy link
Contributor

@lifepuzzlefun lifepuzzlefun commented Mar 12, 2022

fix #3968

  1. avoid java reflection setAccessible each time
  2. direct compare field Class without getCanonicalName.

WJL3333 added 4 commits March 12, 2022 19:07
@lifepuzzlefun lifepuzzlefun changed the title RemotingCommand decodeCommandCustomHeader optimized. [ISSUE #3968]RemotingCommand decodeCommandCustomHeader optimized. Mar 12, 2022
@codecov-commenter
Copy link

codecov-commenter commented Mar 12, 2022

Codecov Report

Merging #3965 (b91a52e) into develop (40d9505) will increase coverage by 0.20%.
The diff coverage is 70.58%.

@@              Coverage Diff              @@
##             develop    #3965      +/-   ##
=============================================
+ Coverage      47.68%   47.88%   +0.20%     
- Complexity      4972     5000      +28     
=============================================
  Files            633      633              
  Lines          42579    42510      -69     
  Branches        5589     5574      -15     
=============================================
+ Hits           20305    20358      +53     
+ Misses         19764    19651     -113     
+ Partials        2510     2501       -9     
Impacted Files Coverage Δ
...he/rocketmq/remoting/protocol/RemotingCommand.java 77.25% <70.58%> (-1.38%) ⬇️
...ava/org/apache/rocketmq/filter/util/BitsArray.java 59.82% <0.00%> (-2.57%) ⬇️
...a/org/apache/rocketmq/filter/util/BloomFilter.java 59.13% <0.00%> (-2.16%) ⬇️
...mq/client/impl/consumer/RebalanceLitePullImpl.java 72.05% <0.00%> (-1.48%) ⬇️
...e/rocketmq/client/impl/consumer/RebalanceImpl.java 43.75% <0.00%> (-0.79%) ⬇️
...etmq/client/latency/LatencyFaultToleranceImpl.java 49.35% <0.00%> (-0.65%) ⬇️
...ent/impl/consumer/DefaultLitePullConsumerImpl.java 68.79% <0.00%> (-0.52%) ⬇️
...che/rocketmq/acl/plain/PlainPermissionManager.java 75.70% <0.00%> (-0.47%) ⬇️
...he/rocketmq/client/impl/consumer/ProcessQueue.java 61.92% <0.00%> (-0.46%) ⬇️
...ain/java/org/apache/rocketmq/store/MappedFile.java 51.40% <0.00%> (-0.36%) ⬇️
... and 13 more

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 40d9505...b91a52e. Read the comment docs.

@coveralls
Copy link

Coverage Status

Coverage increased (+0.003%) to 51.761% when pulling 6b21f89 on WJL3333:optimize_remoting_command_decode into 40d9505 on apache:develop.

@coveralls
Copy link

coveralls commented Mar 12, 2022

Coverage Status

Coverage increased (+0.2%) to 51.934% when pulling b91a52e on WJL3333:optimize_remoting_command_decode into 40d9505 on apache:develop.


public static RemotingCommand createResponseCommand(int code, String remark,
Class<? extends CommandCustomHeader> classHeader) {
Class<? extends CommandCustomHeader> classHeader) {
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert irrelevant modifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.


public CommandCustomHeader decodeCommandCustomHeader(
Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
Class<? extends CommandCustomHeader> classHeader) throws RemotingCommandException {
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert irrelevant modifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

} catch (InstantiationException e) {
return null;
} catch (IllegalAccessException e) {
} catch (InstantiationException | IllegalAccessException e) {
Copy link
Contributor

Choose a reason for hiding this comment

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

since 4.9.3 we should keep compatible under java 1.6, so you should revert this change.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

if (fields == null) {
fields = classHeader.getDeclaredFields();

fields = Arrays.stream(fields)
Copy link
Contributor

Choose a reason for hiding this comment

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

1.6 incompatible

Copy link
Contributor Author

Choose a reason for hiding this comment

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

fixed. and this remind me to avoid create new Field[] here which improve the performance! thank you~

return "RemotingCommand [code=" + code + ", language=" + language + ", version=" + version + ", opaque=" + opaque + ", flag(B)="
+ Integer.toBinaryString(flag) + ", remark=" + remark + ", extFields=" + extFields + ", serializeTypeCurrentRPC="
+ serializeTypeCurrentRPC + "]";
+ Integer.toBinaryString(flag) + ", remark=" + remark + ", extFields=" + extFields + ", serializeTypeCurrentRPC="
Copy link
Contributor

Choose a reason for hiding this comment

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

please revert irrelevant modifications.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

done.

@lifepuzzlefun lifepuzzlefun requested a review from areyouok March 15, 2022 04:55
Copy link
Contributor

@areyouok areyouok left a comment

Choose a reason for hiding this comment

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

I approve this PR.

but I don't known if we should add a module. maybe you can run the test locally.

let's listen to other person's opinion

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[Performance] RemotingCommand decodeCommandCustomHeader optimize

6 participants