-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-28209][CORE][SHUFFLE] Proposed new shuffle writer API #25007
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
Closed
Closed
Changes from 1 commit
Commits
Show all changes
33 commits
Select commit
Hold shift + click to select a range
1957e82
[SPARK-25299] Introduce the new shuffle writer API (#5) (#520)
mccheah 857552a
[SPARK-25299] Local shuffle implementation of the shuffle writer API …
mccheah d13037f
[SPARK-25299] Make UnsafeShuffleWriter use the new API (#536)
mccheah 8f5fb60
[SPARK-25299] Use the shuffle writer plugin for the SortShuffleWriter…
mccheah e17c7ea
[SPARK-25299] Shuffle locations api (#517)
mccheah 3f0c131
[SPARK-25299] Move shuffle writers back to being given specific parti…
mccheah f982df7
[SPARK-25299] Don't set map status twice in bypass merge sort shuffle…
mccheah 6891197
[SPARK-25299] Propose a new NIO transfer API for partition writing. (…
mccheah 7b44ed2
Remove shuffle location support.
mccheah df75f1f
Remove changes to UnsafeShuffleWriter
mccheah a8558af
Revert changes for SortShuffleWriter
mccheah 806d7bb
Revert a bunch of other stuff
mccheah 3167030
More reverts
mccheah 70f59db
Set task contexts in failing test
mccheah 3083d86
Fix style
mccheah 4c3d692
Check for null on the block manager as well.
mccheah 2421c92
Add task attempt id in the APIs
mccheah 982f207
Address comments
mccheah 594d1e2
Fix style
mccheah 66aae91
Address comments.
mccheah 8b432f9
Merge remote-tracking branch 'origin/master' into spark-shuffle-write…
mccheah 9f597dd
Address comments.
mccheah 86c1829
Restructure test
mccheah a7885ae
Add ShuffleWriteMetricsReporter to the createMapOutputWriter API.
mccheah 9893c6c
Add more documentation
mccheah cd897e7
REfactor reading records from file in test
mccheah 9f17b9b
Address comments
mccheah e53a001
Code tags
mccheah 56fa450
Add some docs
mccheah b8b7b8d
Change mockito format in BypassMergeSortShuffleWriterSuite
mccheah 2d29404
Remove metrics from the API.
mccheah 06ea01a
Address more comments.
mccheah 7dceec9
Args per line
mccheah 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
Address more comments.
- Loading branch information
commit 06ea01afc0660025564acff8f1d1e695a72a35cc
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
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -22,6 +22,7 @@ | |
| import java.io.IOException; | ||
| import java.io.OutputStream; | ||
| import java.nio.channels.FileChannel; | ||
| import java.util.Optional; | ||
| import javax.annotation.Nullable; | ||
|
|
||
| import scala.None$; | ||
|
|
@@ -205,45 +206,23 @@ private long[] writePartitionedData(ShuffleMapOutputWriter mapOutputWriter) thro | |
| final File file = partitionWriterSegments[i].file(); | ||
| ShufflePartitionWriter writer = mapOutputWriter.getPartitionWriter(i); | ||
| if (file.exists()) { | ||
| boolean copyThrewException = true; | ||
| if (transferToEnabled) { | ||
| FileInputStream in = new FileInputStream(file); | ||
| // Using WritableByteChannelWrapper to make resource closing consistent between | ||
| // this implementation and UnsafeShuffleWriter. | ||
| try { | ||
| WritableByteChannelWrapper outputChannel = writer.openChannelWrapper(); | ||
| try (FileChannel inputChannel = in.getChannel()) { | ||
| Utils.copyFileStreamNIO( | ||
| inputChannel, outputChannel.channel(), 0L, inputChannel.size()); | ||
| copyThrewException = false; | ||
| } finally { | ||
| Closeables.close(outputChannel, copyThrewException); | ||
| } | ||
| } finally { | ||
| Closeables.close(in, copyThrewException); | ||
| Optional<WritableByteChannelWrapper> maybeOutputChannel = writer.openChannelWrapper(); | ||
| if (maybeOutputChannel.isPresent()) { | ||
| writePartitionedDataWithChannel(file, maybeOutputChannel.get()); | ||
| } else { | ||
| writePartitionedDataWithStream(file, writer); | ||
| } | ||
| } else { | ||
| FileInputStream in = new FileInputStream(file); | ||
| OutputStream outputStream; | ||
| try { | ||
| outputStream = writer.openStream(); | ||
| try { | ||
| Utils.copyStream(in, outputStream, false, false); | ||
| copyThrewException = false; | ||
| } finally { | ||
| Closeables.close(outputStream, copyThrewException); | ||
| } | ||
| } finally { | ||
| Closeables.close(in, copyThrewException); | ||
| } | ||
| writePartitionedDataWithStream(file, writer); | ||
| } | ||
| if (!file.delete()) { | ||
| logger.error("Unable to delete file for partition {}", i); | ||
| } | ||
| } | ||
| long numBytesWritten = writer.getNumBytesWritten(); | ||
| lengths[i] = numBytesWritten; | ||
| writeMetrics.incBytesWritten(numBytesWritten); | ||
| lengths[i] = writer.getNumBytesWritten(); | ||
| } | ||
| } finally { | ||
| writeMetrics.incWriteTime(System.nanoTime() - writeStartTime); | ||
|
|
@@ -252,6 +231,41 @@ private long[] writePartitionedData(ShuffleMapOutputWriter mapOutputWriter) thro | |
| return lengths; | ||
| } | ||
|
|
||
| private void writePartitionedDataWithChannel( | ||
| File file, WritableByteChannelWrapper outputChannel) throws IOException { | ||
|
||
| boolean copyThrewException = true; | ||
| try { | ||
| FileInputStream in = new FileInputStream(file); | ||
| try (FileChannel inputChannel = in.getChannel()) { | ||
| Utils.copyFileStreamNIO( | ||
| inputChannel, outputChannel.channel(), 0L, inputChannel.size()); | ||
| copyThrewException = false; | ||
| } finally { | ||
| Closeables.close(in, copyThrewException); | ||
| } | ||
| } finally { | ||
| Closeables.close(outputChannel, copyThrewException); | ||
| } | ||
| } | ||
|
|
||
| private void writePartitionedDataWithStream(File file, ShufflePartitionWriter writer) | ||
| throws IOException { | ||
| boolean copyThrewException = true; | ||
| FileInputStream in = new FileInputStream(file); | ||
| OutputStream outputStream; | ||
| try { | ||
| outputStream = writer.openStream(); | ||
| try { | ||
| Utils.copyStream(in, outputStream, false, false); | ||
| copyThrewException = false; | ||
| } finally { | ||
| Closeables.close(outputStream, copyThrewException); | ||
| } | ||
| } finally { | ||
| Closeables.close(in, copyThrewException); | ||
| } | ||
| } | ||
|
|
||
| @Override | ||
| public Option<MapStatus> stop(boolean success) { | ||
| if (stopping) { | ||
|
|
||
49 changes: 0 additions & 49 deletions
49
core/src/main/java/org/apache/spark/shuffle/sort/io/DefaultWritableByteChannelWrapper.java
This file was deleted.
Oops, something went wrong.
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
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.
nit: white space between different import groups.