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] refactor: simplify ShuffleWriteClientImpl#genServerToBlocks() #594

Merged
merged 17 commits into from
Feb 13, 2023

Conversation

kaijchen
Copy link
Contributor

What changes were proposed in this pull request?

Simplify ShuffleWriteClientImpl#genServerToBlocks().

Why are the changes needed?

Simplify code logic.

Does this PR introduce any user-facing change?

No.

How was this patch tested?

Covered by ShuffleWriteClientImplTest#testSendDataWithDefectiveServers().

@codecov-commenter
Copy link

codecov-commenter commented Feb 10, 2023

Codecov Report

Merging #594 (dddbc19) into master (fdc2743) will increase coverage by 0.01%.
The diff coverage is 88.88%.

@@             Coverage Diff              @@
##             master     #594      +/-   ##
============================================
+ Coverage     60.84%   60.85%   +0.01%     
- Complexity     1797     1800       +3     
============================================
  Files           214      214              
  Lines         12398    12387      -11     
  Branches       1051     1044       -7     
============================================
- Hits           7543     7538       -5     
+ Misses         4445     4444       -1     
+ Partials        410      405       -5     
Impacted Files Coverage Δ
...he/uniffle/client/impl/ShuffleWriteClientImpl.java 33.66% <88.88%> (-0.79%) ⬇️
...pache/hadoop/mapreduce/task/reduce/RssFetcher.java 92.30% <0.00%> (+1.53%) ⬆️

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

@kaijchen kaijchen marked this pull request as draft February 10, 2023 12:23
@kaijchen kaijchen marked this pull request as ready for review February 10, 2023 13:01
@kaijchen kaijchen changed the title refactor: simplify ShuffleWriteClientImpl#genServerToBlocks() [MINOR] refactor: simplify ShuffleWriteClientImpl#genServerToBlocks() Feb 10, 2023
@xianjingfeng
Copy link
Member

This change is graceful, but i think the performance will be degraded. I don't recommend using lambda in critical path if it brings redundant loop operation.

@kaijchen
Copy link
Contributor Author

if it brings redundant loop operation.

Where does it bring redundant loop operation?

@kaijchen
Copy link
Contributor Author

Actually we can avoid collecting to list and do it in one pass by reverting 57721a3

@xianjingfeng
Copy link
Member

if it brings redundant loop operation.

Where does it bring redundant loop operation?

I just misread. 😂

break;
}
Stream<ShuffleServerInfo> servers;
if (replica > 1 && excludeDefectiveServers) {
Copy link
Member

Choose a reason for hiding this comment

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

Change to replica > 1 && excludeDefectiveServers && !defectiveServers.isEmpty()?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Copy link
Member

Choose a reason for hiding this comment

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

It is OK for me.

.add(sbi);
}
if (excludeServers != null) {
excludeServers.addAll(selected);
Copy link
Member

Choose a reason for hiding this comment

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

How about put this logic after limit of the follow line?

List<ShuffleServerInfo> selected = servers.limit(replicaNum).collect(Collectors.toList());

Copy link
Member

Choose a reason for hiding this comment

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

I mean servers.limit(replicaNum).map((server) -> excludeServers.add(server)).collect(Collectors.toList());

Copy link
Contributor Author

Choose a reason for hiding this comment

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

OK, let's just avoid collect to list.

Copy link
Member

@xianjingfeng xianjingfeng 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 7a8cdb0 into apache:master Feb 13, 2023
@kaijchen
Copy link
Contributor Author

Thanks @xianjingfeng for the review.

@kaijchen kaijchen deleted the refactor-genServerToBlocks branch February 13, 2023 10:01
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

3 participants