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

Add shuffleSegmentPusher for data shuffle #8115

Merged
merged 19 commits into from
Aug 5, 2019

Conversation

jihoonson
Copy link
Contributor

This PR is for #8061 and based on #8114.

Description

ShuffleDataSegmentPusher is a dataSegmentPusher used for writing shuffle data in local storage.

ShuffleDataSegmentPusher uses IntermediaryDataManager internally which coordinates the segment writes in a round-robin fashion per supervisor task across sub tasks. This is to fully utilize the local disk bandwidth for shuffle.

The middleManager and the indexer can use this. However, with the middleManager, each task uses a separate IntermediaryDataManager instance. This could potentially result in two issues:

  • The distribution of shuffle segments can be suboptimal across local storage locations.
  • IntermediaryDataSegment needs to smoosh segment files into larger ones to avoid "too many open files" problem. This could also be an issue if there are a lot of tasks since IntermediaryDataSegment can't smoosh files across tasks with middleManager.

I think this would be ok for now and could be improved if required in the future.


This PR has:

  • been self-reviewed.
  • added unit tests or modified existing tests to cover new code paths.

@jihoonson jihoonson changed the title Add shuffleSegmentPusher which is a dataSegmentPusher used for writin… Add shuffleSegmentPusher which is a dataSegmentPusher used for writing shuffle data in local storage Jul 19, 2019
@jihoonson jihoonson changed the title Add shuffleSegmentPusher which is a dataSegmentPusher used for writing shuffle data in local storage Add shuffleSegmentPusher for data shuffle Jul 19, 2019
@himanshug
Copy link
Contributor

/subscribe

@jihoonson jihoonson requested a review from himanshug July 27, 2019 17:02
@jihoonson
Copy link
Contributor Author

@himanshug I requested a review to you :)

@himanshug
Copy link
Contributor

@jihoonson sure, I did want to go through it.

final String relativeSegmentPath = localtionPath
.relativize(eachFile.toPath().toAbsolutePath())
.toString();
final File reservedFile = location.reserve(
Copy link
Contributor

@himanshug himanshug Jul 29, 2019

Choose a reason for hiding this comment

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

couldn't understand why we need to do this, can you please add some comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Added.

// Create a zipped segment in a temp directory.
final File taskTempDir = taskConfig.getTaskTempDir(subTaskId);
if (taskTempDir.mkdirs()) {
taskTempDir.deleteOnExit();
Copy link
Contributor

Choose a reason for hiding this comment

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

this will delete on jvm exit, it is probably ok for existing peon processes as they do exit but wouldn't log anything if jvm was not able to delete this location at exit.
it wouldn't work for the long running indexer process
I think we should do the cleanup in the code.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Hmm, yeah. Don't remember why I wrote this code. Fixed to clean up properly.

taskTempDir.deleteOnExit();
}
final File tempZippedFile = new File(taskTempDir, segment.getId().toString());
final long unzippedSizeBytes = CompressionUtils.zip(segmentDir, tempZippedFile, true);
Copy link
Contributor

Choose a reason for hiding this comment

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

fsync=true here is useless as this is only a temp location

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

if (destFile != null) {
try {
FileUtils.forceMkdirParent(destFile);
StreamUtils.retryCopy(
Copy link
Contributor

Choose a reason for hiding this comment

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

here we should use FileUtils.writeAtomically(..)

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

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

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

overall lgtm, +1 after @himanshug's comments are addressed

import java.util.Map;

/**
* DataSegmentPusher used for storing intermeidary data in local storage during data shuffle of native parallel
Copy link
Member

Choose a reason for hiding this comment

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

typo: intermeidary-> intermediary

Copy link
Contributor Author

Choose a reason for hiding this comment

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

👍

@@ -174,6 +184,19 @@ private void discoverSupervisorTaskPartitions()
supervisorTaskCheckTimes.computeIfAbsent(
supervisorTaskId,
k -> {
for (File eachFile : FileUtils.listFiles(supervisorTaskDir, null, true)) {
final String relativeSegmentPath = localtionPath
Copy link
Member

Choose a reason for hiding this comment

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

typo: localtionPath -> locationPath

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

@clintropolis clintropolis left a comment

Choose a reason for hiding this comment

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

👍

@jihoonson
Copy link
Contributor Author

@himanshug do you have more comments?

@himanshug himanshug merged commit ab5b3be into apache:master Aug 5, 2019
@jihoonson
Copy link
Contributor Author

@himanshug @clintropolis thank you for the review.

@clintropolis clintropolis added this to the 0.16.0 milestone Aug 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants