-
Notifications
You must be signed in to change notification settings - Fork 457
[CELEBORN-2439][TEZ] Report accurate partition statistics for shuffle output #3821
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
Open
SparksFyz
wants to merge
1
commit into
apache:main
Choose a base branch
from
SparksFyz:fyz/CELEBORN-2439
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
181 changes: 181 additions & 0 deletions
181
client-tez/tez/src/test/java/org/apache/celeborn/client/CelebornTezWriterSuiteJ.java
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,181 @@ | ||
| /* | ||
| * Licensed to the Apache Software Foundation (ASF) under one or more | ||
| * contributor license agreements. See the NOTICE file distributed with | ||
| * this work for additional information regarding copyright ownership. | ||
| * The ASF licenses this file to You under the Apache License, Version 2.0 | ||
| * (the "License"); you may not use this file except in compliance with | ||
| * the License. You may obtain a copy of the License at | ||
| * | ||
| * http://www.apache.org/licenses/LICENSE-2.0 | ||
| * | ||
| * Unless required by applicable law or agreed to in writing, software | ||
| * distributed under the License is distributed on an "AS IS" BASIS, | ||
| * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
| * See the License for the specific language governing permissions and | ||
| * limitations under the License. | ||
| */ | ||
|
|
||
| package org.apache.celeborn.client; | ||
|
|
||
| import static org.junit.Assert.assertArrayEquals; | ||
| import static org.mockito.ArgumentMatchers.any; | ||
| import static org.mockito.ArgumentMatchers.anyInt; | ||
| import static org.mockito.ArgumentMatchers.anyString; | ||
| import static org.mockito.ArgumentMatchers.eq; | ||
| import static org.mockito.Mockito.doAnswer; | ||
| import static org.mockito.Mockito.inOrder; | ||
| import static org.mockito.Mockito.mock; | ||
| import static org.mockito.Mockito.when; | ||
|
|
||
| import java.util.concurrent.atomic.LongAdder; | ||
|
|
||
| import org.junit.Test; | ||
| import org.mockito.InOrder; | ||
|
|
||
| import org.apache.celeborn.client.write.DataPusher; | ||
| import org.apache.celeborn.common.CelebornConf; | ||
| import org.apache.celeborn.common.write.PushState; | ||
|
|
||
| public class CelebornTezWriterSuiteJ { | ||
|
|
||
| private static final int SHUFFLE_ID = 1; | ||
| private static final int MAP_ID = 2; | ||
| private static final int ATTEMPT_ID = 3; | ||
| private static final int NUM_MAPPERS = 4; | ||
| private static final int NUM_PARTITIONS = 3; | ||
|
|
||
| @Test | ||
| public void testSnapshotPartitionStats() { | ||
| LongAdder[] mapStatusLengths = new LongAdder[3]; | ||
| for (int i = 0; i < mapStatusLengths.length; i++) { | ||
| mapStatusLengths[i] = new LongAdder(); | ||
| } | ||
| mapStatusLengths[0].add(1016); | ||
| mapStatusLengths[1].add(2016); | ||
| mapStatusLengths[0].add(3016); | ||
|
|
||
| long[] partitionStats = CelebornTezWriter.snapshotPartitionStats(mapStatusLengths); | ||
| assertArrayEquals(new long[] {4032, 2016, 0}, partitionStats); | ||
|
|
||
| mapStatusLengths[2].add(4016); | ||
| assertArrayEquals(new long[] {4032, 2016, 0}, partitionStats); | ||
| assertArrayEquals( | ||
| new long[] {4032, 2016, 4016}, CelebornTezWriter.snapshotPartitionStats(mapStatusLengths)); | ||
| } | ||
|
|
||
| @Test | ||
| public void testMergeDataUsesBytesWrittenByShuffleClient() throws Exception { | ||
| CelebornConf conf = createConf(); | ||
| ShuffleClient shuffleClient = createShuffleClient(conf); | ||
| when(shuffleClient.mergeData( | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt(), | ||
| any(byte[].class), | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt())) | ||
| .thenAnswer( | ||
| invocation -> { | ||
| int partitionId = invocation.getArgument(3); | ||
| int length = invocation.getArgument(6); | ||
| return partitionId * 1000 + length; | ||
| }); | ||
|
|
||
| CelebornTezWriter writer = createWriter(conf, shuffleClient); | ||
| writer.mergeData(0, new byte[10], 10); | ||
| writer.mergeData(1, new byte[20], 20); | ||
| writer.mergeData(0, new byte[30], 30); | ||
|
|
||
| assertArrayEquals(new long[] {40, 1020, 0}, writer.getPartitionStats()); | ||
| writer.close(); | ||
| } | ||
|
|
||
| @Test | ||
| public void testAsyncPushIsIncludedInPartitionStatsAfterClose() throws Exception { | ||
| CelebornConf conf = createConf(); | ||
| ShuffleClient shuffleClient = createShuffleClient(conf); | ||
| when(shuffleClient.pushData( | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt(), | ||
| any(byte[].class), | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt(), | ||
| anyInt())) | ||
| .thenAnswer( | ||
| invocation -> { | ||
| int partitionId = invocation.getArgument(3); | ||
| int length = invocation.getArgument(6); | ||
| return partitionId * 1000 + length; | ||
| }); | ||
|
|
||
| CelebornTezWriter writer = createWriter(conf, shuffleClient); | ||
| writer.pushData(2, new byte[50], 50); | ||
| writer.close(); | ||
|
|
||
| assertArrayEquals(new long[] {0, 0, 2050}, writer.getPartitionStats()); | ||
| InOrder inOrder = inOrder(shuffleClient); | ||
| inOrder | ||
| .verify(shuffleClient) | ||
| .pushData( | ||
| eq(SHUFFLE_ID), | ||
| eq(MAP_ID), | ||
| eq(ATTEMPT_ID), | ||
| eq(2), | ||
| any(byte[].class), | ||
| eq(0), | ||
| eq(50), | ||
| eq(NUM_MAPPERS), | ||
| eq(NUM_PARTITIONS)); | ||
| inOrder.verify(shuffleClient).pushMergedData(SHUFFLE_ID, MAP_ID, ATTEMPT_ID); | ||
| inOrder | ||
| .verify(shuffleClient) | ||
| .mapperEnd(SHUFFLE_ID, MAP_ID, ATTEMPT_ID, NUM_MAPPERS, NUM_PARTITIONS); | ||
| } | ||
|
|
||
| @Test | ||
| public void testCloseWaitsForDataPusherBeforeFinalizingMapper() throws Exception { | ||
| ShuffleClient shuffleClient = mock(ShuffleClient.class); | ||
| DataPusher dataPusher = mock(DataPusher.class); | ||
| CelebornTezWriter writer = | ||
| new CelebornTezWriter( | ||
| SHUFFLE_ID, MAP_ID, ATTEMPT_ID, NUM_MAPPERS, NUM_PARTITIONS, shuffleClient, dataPusher); | ||
|
|
||
| writer.close(); | ||
|
|
||
| InOrder inOrder = inOrder(dataPusher, shuffleClient); | ||
| inOrder.verify(dataPusher).waitOnTermination(); | ||
| inOrder.verify(shuffleClient).pushMergedData(SHUFFLE_ID, MAP_ID, ATTEMPT_ID); | ||
| inOrder | ||
| .verify(shuffleClient) | ||
| .mapperEnd(SHUFFLE_ID, MAP_ID, ATTEMPT_ID, NUM_MAPPERS, NUM_PARTITIONS); | ||
| } | ||
|
|
||
| private static CelebornConf createConf() { | ||
| CelebornConf conf = new CelebornConf(); | ||
| conf.set(CelebornConf.CLIENT_PUSH_QUEUE_CAPACITY().key(), "2"); | ||
| conf.set(CelebornConf.CLIENT_PUSH_BUFFER_MAX_SIZE().key(), "1024"); | ||
| return conf; | ||
| } | ||
|
|
||
| private static ShuffleClient createShuffleClient(CelebornConf conf) throws Exception { | ||
| ShuffleClient shuffleClient = mock(ShuffleClient.class); | ||
| when(shuffleClient.getPushState(anyString())).thenReturn(new PushState(conf)); | ||
| when(shuffleClient.getPartitionLocation(anyInt(), anyInt(), anyInt())).thenReturn(null); | ||
| doAnswer(invocation -> null) | ||
| .when(shuffleClient) | ||
| .computeBatchCRC( | ||
| anyInt(), anyInt(), anyInt(), anyInt(), any(byte[].class), anyInt(), anyInt()); | ||
| return shuffleClient; | ||
| } | ||
|
|
||
| private static CelebornTezWriter createWriter(CelebornConf conf, ShuffleClient shuffleClient) { | ||
| return new CelebornTezWriter( | ||
| SHUFFLE_ID, MAP_ID, ATTEMPT_ID, 4L, NUM_MAPPERS, NUM_PARTITIONS, conf, shuffleClient); | ||
| } | ||
| } | ||
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Could we add focused coverage for the two Tez consumers changed in this patch? This suite verifies the counters inside CelebornTezWriter, but it would still pass if CelebornSorter or CelebornUnorderedPartitionedKVWriter failed to expose the snapshot, or if disabled partition-stat reporting returned a non-null array. Exercising enabled and disabled TEZ_RUNTIME_REPORT_PARTITION_STATS through both paths would protect the user-visible behavior this PR is fixing.
Uh oh!
There was an error while loading. Please reload this page.
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.
@SteNicholas Thanks for the review. I added focused tests for both CelebornSorter and CelebornUnorderedPartitionedKVWriter, covering explicit PRECISE, the default MEMORY_OPTIMIZED, and disabled (NONE) partition-stat reporting. The tests verify that enabled reporting exposes the snapshot after CelebornTezWriter is closed, while disabled reporting returns null without querying the writer.