Skip to content
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

[Minor] Optimize ShuffleServerInfo#hashCode #538

Merged
merged 2 commits into from
Feb 2, 2023

Conversation

xianjingfeng
Copy link
Member

What changes were proposed in this pull request?

Optimize ShuffleServerInfo#hashCode

Why are the changes needed?

For better performence.

Does this PR introduce any user-facing change?

No

How was this patch tested?

No need

@codecov-commenter
Copy link

codecov-commenter commented Feb 2, 2023

Codecov Report

Merging #538 (6478995) into master (ebbe2db) will increase coverage by 0.05%.
The diff coverage is 100.00%.

@@             Coverage Diff              @@
##             master     #538      +/-   ##
============================================
+ Coverage     60.21%   60.26%   +0.05%     
- Complexity     1784     1785       +1     
============================================
  Files           205      205              
  Lines         11557    11557              
  Branches       1042     1042              
============================================
+ Hits           6959     6965       +6     
+ Misses         4190     4186       -4     
+ Partials        408      406       -2     
Impacted Files Coverage Δ
...a/org/apache/uniffle/common/ShuffleServerInfo.java 75.00% <100.00%> (ø)
...y/kubernetes/operator/pkg/webhook/inspector/rss.go 47.70% <0.00%> (ø)
.../apache/uniffle/coordinator/ClientConfManager.java 92.95% <0.00%> (ø)
...inator/access/checker/AccessCandidatesChecker.java 85.50% <0.00%> (ø)
...he/uniffle/server/buffer/ShuffleBufferManager.java 83.98% <0.00%> (+0.65%) ⬆️
...bernetes/operator/pkg/controller/controller/rss.go 33.22% <0.00%> (+0.74%) ⬆️

📣 We’re building smart automated test selection to slash your CI/CD build times. Learn more

@@ -54,7 +54,7 @@ public int getPort() {

@Override
public int hashCode() {
return host.hashCode();
return id.hashCode();
Copy link
Contributor

@kaijchen kaijchen Feb 2, 2023

Choose a reason for hiding this comment

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

Why not include all three fields (id, host, port) in hashCode()?
For example:

Objects.hash(id, host, port)

Copy link
Member Author

Choose a reason for hiding this comment

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

By default id = host + "-" + port, so id is enough.

Copy link
Contributor

Choose a reason for hiding this comment

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

By default id = host + "-" + port, so id is enough.

Should we remove the constructor at line 37?

Copy link
Member Author

Choose a reason for hiding this comment

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

No. In some cases, the id does not need to be recalculated.

Copy link
Contributor

Choose a reason for hiding this comment

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

OK. Can you add some comments here to make future reviewer be aware of it.

Copy link
Member Author

Choose a reason for hiding this comment

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

Done

Copy link
Contributor

@jerqi jerqi left a comment

Choose a reason for hiding this comment

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

LGTM

@kaijchen kaijchen merged commit 29526d7 into apache:master Feb 2, 2023
@xianjingfeng xianjingfeng deleted the minor branch February 16, 2023 03:22
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.

None yet

5 participants