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

[Improvement] Only report to the shuffle servers that owns the blocks #539

Merged
merged 6 commits into from
Feb 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,28 @@ public void reportShuffleResult(
Map<ShuffleServerInfo, List<Integer>> groupedPartitions = Maps.newHashMap();
Map<Integer, Integer> partitionReportTracker = Maps.newHashMap();
for (Map.Entry<Integer, List<ShuffleServerInfo>> entry : partitionToServers.entrySet()) {
int partitionIdx = entry.getKey();
for (ShuffleServerInfo ssi : entry.getValue()) {
if (!groupedPartitions.containsKey(ssi)) {
groupedPartitions.putIfAbsent(ssi, Lists.newArrayList());
groupedPartitions.put(ssi, Lists.newArrayList());
advancedxy marked this conversation as resolved.
Show resolved Hide resolved
}
groupedPartitions.get(ssi).add(entry.getKey());
groupedPartitions.get(ssi).add(partitionIdx);
}
if (CollectionUtils.isNotEmpty(partitionToBlockIds.get(partitionIdx))) {
partitionReportTracker.putIfAbsent(partitionIdx, 0);
}
partitionReportTracker.putIfAbsent(entry.getKey(), 0);
}

for (Map.Entry<ShuffleServerInfo, List<Integer>> entry : groupedPartitions.entrySet()) {
Map<Integer, List<Long>> requestBlockIds = Maps.newHashMap();
for (Integer partitionId : entry.getValue()) {
requestBlockIds.put(partitionId, partitionToBlockIds.get(partitionId));
List<Long> blockIds = partitionToBlockIds.get(partitionId);
if (CollectionUtils.isNotEmpty(blockIds)) {
requestBlockIds.put(partitionId, blockIds);
}
}
if (requestBlockIds.isEmpty()) {
continue;
}
RssReportShuffleResultRequest request = new RssReportShuffleResultRequest(
appId, shuffleId, taskAttemptId, requestBlockIds, bitmapNum);
Expand All @@ -541,7 +551,7 @@ public void reportShuffleResult(
if (response.getStatusCode() == ResponseStatusCode.SUCCESS) {
LOG.info("Report shuffle result to " + ssi + " for appId[" + appId
+ "], shuffleId[" + shuffleId + "] successfully");
for (Integer partitionId : entry.getValue()) {
for (Integer partitionId : requestBlockIds.keySet()) {
partitionReportTracker.put(partitionId, partitionReportTracker.get(partitionId) + 1);
}
} else {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,57 @@ public void rpcFailTest() throws Exception {
assertEquals(blockIdBitmap, report);
}

@Test
public void reportBlocksToShuffleServerIfNecessary() {
String testAppId = "reportBlocksToShuffleServerIfNecessary_appId";

shuffleWriteClientImpl.registerShuffle(
shuffleServerInfo1,
testAppId,
1,
Lists.newArrayList(new PartitionRange(1, 1)),
new RemoteStorageInfo(""),
ShuffleDataDistributionType.NORMAL
);

shuffleWriteClientImpl.registerShuffle(
shuffleServerInfo2,
testAppId,
1,
Lists.newArrayList(new PartitionRange(2, 2)),
new RemoteStorageInfo(""),
ShuffleDataDistributionType.NORMAL
);

Map<Integer, List<ShuffleServerInfo>> partitionToServers = Maps.newHashMap();
partitionToServers.put(1, Lists.newArrayList(shuffleServerInfo1));
partitionToServers.put(2, Lists.newArrayList(shuffleServerInfo2));
Map<Integer, List<Long>> partitionToBlocks = Maps.newHashMap();
List<Long> blockIds = Lists.newArrayList();

int partitionIdx = 1;
for (int i = 0; i < 5; i++) {
blockIds.add(ClientUtils.getBlockId(partitionIdx, 0, i));
}
partitionToBlocks.put(partitionIdx, blockIds);

// case1
shuffleWriteClientImpl
.reportShuffleResult(partitionToServers, testAppId, 1, 0, partitionToBlocks, 1);
Roaring64NavigableMap bitmap = shuffleWriteClientImpl
.getShuffleResult("GRPC", Sets.newHashSet(shuffleServerInfo1), testAppId,
1, 0);
assertTrue(bitmap.isEmpty());

bitmap = shuffleWriteClientImpl
.getShuffleResult("GRPC", Sets.newHashSet(shuffleServerInfo1), testAppId,
1, partitionIdx);
assertEquals(5, bitmap.getLongCardinality());
for (int i = 0; i < 5; i++) {
assertTrue(bitmap.contains(partitionToBlocks.get(1).get(i)));
}
}

@Test
public void reportMultipleServerTest() throws Exception {
String testAppId = "reportMultipleServerTest";
Expand Down