-
Notifications
You must be signed in to change notification settings - Fork 443
TEZ-4757: APPROXIMATE_INPUT_RECORDS over-counts the rows an input will deliver #540
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
deniskuzZ
wants to merge
1
commit into
apache:master
Choose a base branch
from
deniskuzZ:TEZ-approx-input-records
base: master
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.
+364
−32
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
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -408,6 +408,63 @@ public void testDataMovementEventsWithShuffleData() throws IOException { | |
| } | ||
| } | ||
|
|
||
| /** | ||
| * An input whose partition is empty reports zero rows and must still reach the ShuffleManager: | ||
| * counting it only in numInputs and not in the denominator is what inflated the counter. | ||
| */ | ||
| @Test | ||
| @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) | ||
| public void testAnEmptyPartitionStillReportsItsRecordCount() throws IOException { | ||
| ShuffleManager shuffleManager = mock(ShuffleManager.class); | ||
| ShuffleInputEventHandlerImpl handler = newHandler(shuffleManager, false); | ||
|
|
||
| handler.handleEvents(Collections.singletonList( | ||
| createRecordCountEvent(1, 0, createEmptyPartitionByteString(0), false))); | ||
|
|
||
| verify(shuffleManager).updateApproximateInputRecords(eq(1), eq(0L)); | ||
| verify(shuffleManager).addCompletedInputWithNoData(any()); | ||
| } | ||
|
|
||
| /** The composite path carries the same payload and has to report it too. */ | ||
| @Test | ||
| @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) | ||
| public void testACompositeEventReportsItsRecordCount() throws IOException { | ||
| ShuffleManager shuffleManager = mock(ShuffleManager.class); | ||
| ShuffleInputEventHandlerImpl handler = newHandler(shuffleManager, true); | ||
|
|
||
| handler.handleEvents(Collections.singletonList(createRecordCountEvent(1, 4000, null, true))); | ||
|
|
||
| verify(shuffleManager).updateApproximateInputRecords(eq(1), eq(4000L)); | ||
| } | ||
|
|
||
| /** | ||
| * A source task can emit more rows than an int32 holds. num_record is an int64 so the count | ||
| * survives the wire; passing it as an int would not even compile against that field. | ||
| */ | ||
| @Test | ||
| @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) | ||
| public void testACountAboveIntMaxSurvivesTheWire() throws IOException { | ||
| ShuffleManager shuffleManager = mock(ShuffleManager.class); | ||
| ShuffleInputEventHandlerImpl handler = newHandler(shuffleManager, false); | ||
|
|
||
| handler.handleEvents(Collections.singletonList( | ||
| createRecordCountEvent(1, 3_000_000_000L, null, false))); | ||
|
|
||
| verify(shuffleManager).updateApproximateInputRecords(eq(1), eq(3_000_000_000L)); | ||
| } | ||
|
|
||
| /** A payload with no record count -- any multi-partition writer -- reports nothing. */ | ||
| @Test | ||
| @Timeout(value = 5000, unit = TimeUnit.MILLISECONDS) | ||
| public void testAPayloadWithoutARecordCountReportsNothing() throws IOException { | ||
| ShuffleManager shuffleManager = mock(ShuffleManager.class); | ||
| ShuffleInputEventHandlerImpl handler = newHandler(shuffleManager, false); | ||
|
|
||
| handler.handleEvents(Collections.singletonList(createDataMovementEvent(0, 1, null))); | ||
|
|
||
| verify(shuffleManager, times(0)).updateApproximateInputRecords(anyInt(), anyLong()); | ||
| } | ||
|
Comment on lines
+456
to
+466
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. while I understand the goal of this unit test, nothing strongly shows a multi-partition writer here, which is confusing, its real goal would be clearer by having said like something below: |
||
|
|
||
| private Event createDataMovementEvent(boolean addSpillDetails, int srcIdx, int targetIdx, | ||
| int spillId, boolean isLastSpill, BitSet emptyPartitions, int numPartitions, int attemptNum) | ||
| throws IOException { | ||
|
|
@@ -438,7 +495,7 @@ private Event createDataMovementEvent(boolean addSpillDetails, int srcIdx, int t | |
| return DataMovementEvent.create(srcIdx, targetIdx, attemptNum, payload); | ||
| } | ||
|
|
||
| private Event createDataMovementEvent(int srcIndex, int targetIndex, | ||
| private DataMovementEventPayloadProto.Builder createPayloadBuilder( | ||
| ByteString emptyPartitionByteString) { | ||
| DataMovementEventPayloadProto.Builder builder = DataMovementEventPayloadProto.newBuilder(); | ||
| builder.setHost(HOST); | ||
|
|
@@ -447,9 +504,29 @@ private Event createDataMovementEvent(int srcIndex, int targetIndex, | |
| if (emptyPartitionByteString != null) { | ||
| builder.setEmptyPartitions(emptyPartitionByteString); | ||
| } | ||
| Event dme = DataMovementEvent | ||
| .create(srcIndex, targetIndex, 0, builder.build().toByteString().asReadOnlyByteBuffer()); | ||
| return dme; | ||
| return builder; | ||
| } | ||
|
|
||
| private Event createDataMovementEvent(int srcIndex, int targetIndex, | ||
| ByteString emptyPartitionByteString) { | ||
| return DataMovementEvent.create(srcIndex, targetIndex, 0, | ||
| createPayloadBuilder(emptyPartitionByteString).build().toByteString() | ||
| .asReadOnlyByteBuffer()); | ||
| } | ||
|
|
||
| private Event createRecordCountEvent(int targetIndex, long numRecord, | ||
| ByteString emptyPartitionByteString, boolean composite) { | ||
| ByteBuffer payload = createPayloadBuilder(emptyPartitionByteString).setNumRecord(numRecord) | ||
| .build().toByteString().asReadOnlyByteBuffer(); | ||
| return composite | ||
| ? CompositeRoutedDataMovementEvent.create(0, targetIndex, 1, 0, payload) | ||
| : DataMovementEvent.create(0, targetIndex, 0, payload); | ||
| } | ||
|
|
||
| private ShuffleInputEventHandlerImpl newHandler(ShuffleManager shuffleManager, | ||
| boolean compositeFetch) { | ||
| return new ShuffleInputEventHandlerImpl(mock(InputContext.class), shuffleManager, | ||
| mock(FetchedInputAllocator.class), null, false, 0, compositeFetch); | ||
| } | ||
|
|
||
| private ByteString createEmptyPartitionByteString(int... emptyPartitions) throws IOException { | ||
|
|
||
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.
DataMovementEventPayloadProtois already imported, I would use it instead