-
Notifications
You must be signed in to change notification settings - Fork 361
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[CELEBORN-1725][FOLLOWUP] Optimize
isAllMapTasksEnd
performance
### What changes were proposed in this pull request? Followup for #2905, using the same logic to optimize `isAllMapTasksEnd` method. ### Why are the changes needed? Address comments: #2905 (review) ### Does this PR introduce _any_ user-facing change? No. ### How was this patch tested? Same logic with #2905 Closes #2959 from turboFei/celeborn_1725_follow. Authored-by: Wang, Fei <[email protected]> Signed-off-by: Shuang <[email protected]>
- Loading branch information
Showing
3 changed files
with
45 additions
and
16 deletions.
There are no files selected for viewing
40 changes: 40 additions & 0 deletions
40
client/src/main/scala/org/apache/celeborn/client/ClientUtils.scala
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 |
---|---|---|
@@ -0,0 +1,40 @@ | ||
/* | ||
* 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 | ||
|
||
object ClientUtils { | ||
|
||
/** | ||
* Check if all the mapper attempts are finished. If any of the attempts is not finished, return false. | ||
* This method checks the attempts array in reverse order, which can be faster if the unfinished attempts | ||
* are more likely to be towards the end of the array. | ||
* | ||
* @param attempts The mapper finished attemptId array. An attempt ID of -1 indicates that the mapper is not finished. | ||
* @return True if all mapper attempts are finished, false otherwise. | ||
*/ | ||
def areAllMapperAttemptsFinished(attempts: Array[Int]): Boolean = { | ||
var i = attempts.length - 1 | ||
while (i >= 0) { | ||
if (attempts(i) < 0) { | ||
return false | ||
} | ||
i -= 1 | ||
} | ||
true | ||
} | ||
} |
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