-
Notifications
You must be signed in to change notification settings - Fork 135
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
[#1398] fix(mr,tez): Make attempId computable and move it to taskAttemptId in BlockId layout. #1418
Open
qijiale76
wants to merge
9
commits into
apache:master
Choose a base branch
from
qijiale76:issue#1398
base: master
Could not load branches
Branch not found: {{ refName }}
Could not load tags
Nothing to show
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 6 commits
Commits
Show all changes
9 commits
Select commit
Hold shift + click to select a range
f2bbf08
fix(MR)(TEZ): Limit attemptId to 4 bit and move it from sequenceNo to…
qijiale76 ba15386
According to the review, modify the code and change taskAttemptId fro…
qijiale76 8787f0d
Resolve failed tests.
qijiale76 8fdfda5
Resolve failed tests.
qijiale76 08311bc
Resolve tez bug.
qijiale76 fdca0a5
Calculate attemptBits from conf.
qijiale76 f84ad00
Resolve failed checkstyle.
qijiale76 ee21967
Update the code according to the review.
qijiale76 bc5585d
fix checkstyle.
qijiale76 File filter
Filter by extension
Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
There are no files selected for viewing
This file contains 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 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 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 | ||||
---|---|---|---|---|---|---|
|
@@ -35,6 +35,7 @@ | |||||
|
||||||
import org.apache.uniffle.client.api.ShuffleWriteClient; | ||||||
import org.apache.uniffle.client.factory.ShuffleClientFactory; | ||||||
import org.apache.uniffle.client.util.ClientUtils; | ||||||
import org.apache.uniffle.common.ShuffleServerInfo; | ||||||
import org.apache.uniffle.common.exception.RssException; | ||||||
import org.apache.uniffle.common.util.BlockIdLayout; | ||||||
|
@@ -44,38 +45,46 @@ public class RssMRUtils { | |||||
|
||||||
private static final Logger LOG = LoggerFactory.getLogger(RssMRUtils.class); | ||||||
private static final BlockIdLayout LAYOUT = BlockIdLayout.DEFAULT; | ||||||
private static final int MAX_ATTEMPT_LENGTH = 4; | ||||||
private static final int MAX_ATTEMPT_ID = (1 << MAX_ATTEMPT_LENGTH) - 1; | ||||||
private static final int MAX_TASK_LENGTH = LAYOUT.taskAttemptIdBits - MAX_ATTEMPT_LENGTH; | ||||||
private static final int MAX_TASK_ID = (1 << MAX_TASK_LENGTH) - 1; | ||||||
|
||||||
// Class TaskAttemptId have two field id and mapId. MR have a trick logic, taskAttemptId will | ||||||
// increase 1000 * (appAttemptId - 1), so we will decrease it. | ||||||
public static long convertTaskAttemptIdToLong(TaskAttemptID taskAttemptID, int appAttemptId) { | ||||||
public static int createRssTaskAttemptId( | ||||||
TaskAttemptID taskAttemptID, int appAttemptId, int maxAttemptNo) { | ||||||
int attemptBits = ClientUtils.getAttemptIdBits(maxAttemptNo); | ||||||
|
||||||
if (appAttemptId < 1) { | ||||||
throw new RssException("appAttemptId " + appAttemptId + " is wrong"); | ||||||
} | ||||||
long lowBytes = taskAttemptID.getId() - (appAttemptId - 1) * 1000L; | ||||||
if (lowBytes > MAX_ATTEMPT_ID || lowBytes < 0) { | ||||||
int attemptId = taskAttemptID.getId() - (appAttemptId - 1) * 1000; | ||||||
if (attemptId > maxAttemptNo || attemptId < 0) { | ||||||
throw new RssException( | ||||||
"TaskAttempt " + taskAttemptID + " low bytes " + lowBytes + " exceed " + MAX_ATTEMPT_ID); | ||||||
"TaskAttempt " + taskAttemptID + " attemptId " + attemptId + " exceed " + maxAttemptNo); | ||||||
} | ||||||
long highBytes = taskAttemptID.getTaskID().getId(); | ||||||
if (highBytes > MAX_TASK_ID || highBytes < 0) { | ||||||
int taskId = taskAttemptID.getTaskID().getId(); | ||||||
|
||||||
int mapIndexBits = 32 - Integer.numberOfLeadingZeros(taskId); | ||||||
qijiale76 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
if (mapIndexBits + attemptBits > LAYOUT.taskAttemptIdBits) { | ||||||
throw new RssException( | ||||||
"TaskAttempt " + taskAttemptID + " high bytes " + highBytes + " exceed " + MAX_TASK_ID); | ||||||
"Observing taskId[" | ||||||
+ taskId | ||||||
+ "] that would produce a taskAttemptId with " | ||||||
+ (mapIndexBits + attemptBits) | ||||||
+ " bits which is larger than the allowed " | ||||||
+ LAYOUT.taskAttemptIdBits | ||||||
+ "]). Please consider providing more bits for taskAttemptIds."); | ||||||
} | ||||||
long taskAttemptId = (highBytes << (MAX_ATTEMPT_LENGTH)) + lowBytes; | ||||||
return LAYOUT.getBlockId(0, 0, taskAttemptId); | ||||||
|
||||||
return (taskId << (attemptBits)) + attemptId; | ||||||
qijiale76 marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
} | ||||||
|
||||||
public static TaskAttemptID createMRTaskAttemptId( | ||||||
JobID jobID, TaskType taskType, long rssTaskAttemptId, int appAttemptId) { | ||||||
JobID jobID, TaskType taskType, int rssTaskAttemptId, int appAttemptId, int maxAttemptNo) { | ||||||
int attemptBits = ClientUtils.getAttemptIdBits(maxAttemptNo); | ||||||
if (appAttemptId < 1) { | ||||||
throw new RssException("appAttemptId " + appAttemptId + " is wrong"); | ||||||
} | ||||||
int task = LAYOUT.getTaskAttemptId(rssTaskAttemptId) >> MAX_ATTEMPT_LENGTH; | ||||||
int attempt = (int) (rssTaskAttemptId & MAX_ATTEMPT_ID); | ||||||
int task = rssTaskAttemptId >> attemptBits; | ||||||
int attempt = rssTaskAttemptId & ((1 << attemptBits) - 1); | ||||||
TaskID taskID = new TaskID(jobID, taskType, task); | ||||||
int id = attempt + 1000 * (appAttemptId - 1); | ||||||
return new TaskAttemptID(taskID, id); | ||||||
|
@@ -230,29 +239,7 @@ public static String getString(Configuration rssJobConf, String key, String defa | |||||
return rssJobConf.get(key, defaultValue); | ||||||
} | ||||||
|
||||||
public static long getBlockId(int partitionId, long taskAttemptId, int nextSeqNo) { | ||||||
if (taskAttemptId < 0 || taskAttemptId > LAYOUT.maxTaskAttemptId) { | ||||||
throw new RssException( | ||||||
"Can't support attemptId [" | ||||||
+ taskAttemptId | ||||||
+ "], the max value should be " | ||||||
+ LAYOUT.maxTaskAttemptId); | ||||||
} | ||||||
if (nextSeqNo < 0 || nextSeqNo > LAYOUT.maxSequenceNo) { | ||||||
throw new RssException( | ||||||
"Can't support sequence [" | ||||||
+ nextSeqNo | ||||||
+ "], the max value should be " | ||||||
+ LAYOUT.maxSequenceNo); | ||||||
} | ||||||
|
||||||
if (partitionId < 0 || partitionId > LAYOUT.maxPartitionId) { | ||||||
throw new RssException( | ||||||
"Can't support partitionId [" | ||||||
+ partitionId | ||||||
+ "], the max value should be " | ||||||
+ LAYOUT.maxPartitionId); | ||||||
} | ||||||
public static long getBlockId(int partitionId, int taskAttemptId, int nextSeqNo) { | ||||||
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. Technically, the
Suggested change
|
||||||
return LAYOUT.getBlockId(nextSeqNo, partitionId, taskAttemptId); | ||||||
} | ||||||
|
||||||
|
This file contains 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 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 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 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 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
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.
I am not sure about restricting
taskAttemptIds
toint
in such places.Here is the situation:
long
task attempt ids (for Tez and MR, (taskId, attemptId) constitutes along
task attempt id, which we restrict toint
for similar reasons as in 2.)long
task attempt ids toint
, since we allow only less that 32 bits for itint
because of thatlong
task attempt ids if that makes no difference for that code, up-castingint
task attempt ids tolong
does not harm, as long as the code works withlong
.This allows to support truly
long
task attempt ids without reverting such code changes in the future.@zuston @jerqi @zhengchenyu what do you think?
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.
@EnricoMi
I think the original taskattemptid is long because it comes from TaskContext::taskAttemptId of spark, which is the unique id of attempt at the app level. MR and Tez inherited the long type, but implemented taskattemptid by bit concatenation of taskid and attemptid in this task.
I think you have changed taskattemptid to the concatenation of taskid and attemptid in #731, and limited it to no more than 32 bits, so int is enough.
What do you think?
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.
Preferring using long for some common methods.