-
Notifications
You must be signed in to change notification settings - Fork 29k
[SPARK-27651][Core] Avoid the network when shuffle blocks are fetched from the same host #25299
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 all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
3fd4f23
Initial version
attilapiros 3da304d
fix mima
attilapiros b1dbe12
fix mima v2.0
attilapiros b604ed2
fix mima v3.0
attilapiros 9cc8375
applying review comments 1.0
attilapiros 56257ff
Remove host-local metrics
attilapiros 833727a
rebase onto master branch
attilapiros d420836
Add local dirs cache to executors
attilapiros 4249655
introduce LRU cache and possible fall back on to remote fetch
attilapiros 249db66
fixing bug and adding test for that
attilapiros 93dfaa9
adding bounded cache to executor side
attilapiros 174e451
fix build error
attilapiros c0e70e0
MIMA fix
attilapiros 4a0979a
asynch getter of host-local execs' dirs
attilapiros eafeb47
fixing test failures (introduced by a merge mistake)
attilapiros 8792931
remove AsyncResponseCallback
attilapiros aa8c4c7
applying review comments
attilapiros 1f53e06
applying review comments
attilapiros d0d5ce7
fixing nits
attilapiros 52037b7
fixing import order
attilapiros 22aa383
log the time of handling host-local blocks
attilapiros da93837
tiny fix: intended to have one logDebug for all host-local blocks wo …
attilapiros 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
81 changes: 81 additions & 0 deletions
81
...fle/src/main/java/org/apache/spark/network/shuffle/protocol/GetLocalDirsForExecutors.java
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 |
|---|---|---|
| @@ -0,0 +1,81 @@ | ||
| /* | ||
| * 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.spark.network.shuffle.protocol; | ||
|
|
||
| import java.util.Arrays; | ||
|
|
||
| import com.google.common.base.Objects; | ||
| import io.netty.buffer.ByteBuf; | ||
|
|
||
| import org.apache.spark.network.protocol.Encoders; | ||
|
|
||
| // Needed by ScalaDoc. See SPARK-7726 | ||
attilapiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import static org.apache.spark.network.shuffle.protocol.BlockTransferMessage.Type; | ||
|
|
||
| /** Request to get the local dirs for the given executors. */ | ||
| public class GetLocalDirsForExecutors extends BlockTransferMessage { | ||
| public final String appId; | ||
| public final String[] execIds; | ||
|
|
||
| public GetLocalDirsForExecutors(String appId, String[] execIds) { | ||
| this.appId = appId; | ||
| this.execIds = execIds; | ||
| } | ||
|
|
||
| @Override | ||
| protected Type type() { return Type.GET_LOCAL_DIRS_FOR_EXECUTORS; } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Objects.hashCode(appId) * 41 + Arrays.hashCode(execIds); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return Objects.toStringHelper(this) | ||
| .add("appId", appId) | ||
| .add("execIds", Arrays.toString(execIds)) | ||
| .toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object other) { | ||
| if (other instanceof GetLocalDirsForExecutors) { | ||
| GetLocalDirsForExecutors o = (GetLocalDirsForExecutors) other; | ||
| return appId.equals(o.appId) && Arrays.equals(execIds, o.execIds); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int encodedLength() { | ||
| return Encoders.Strings.encodedLength(appId) + Encoders.StringArrays.encodedLength(execIds); | ||
| } | ||
|
|
||
| @Override | ||
| public void encode(ByteBuf buf) { | ||
| Encoders.Strings.encode(buf, appId); | ||
| Encoders.StringArrays.encode(buf, execIds); | ||
| } | ||
|
|
||
| public static GetLocalDirsForExecutors decode(ByteBuf buf) { | ||
| String appId = Encoders.Strings.decode(buf); | ||
| String[] execIds = Encoders.StringArrays.decode(buf); | ||
| return new GetLocalDirsForExecutors(appId, execIds); | ||
| } | ||
| } | ||
117 changes: 117 additions & 0 deletions
117
...huffle/src/main/java/org/apache/spark/network/shuffle/protocol/LocalDirsForExecutors.java
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 |
|---|---|---|
| @@ -0,0 +1,117 @@ | ||
| /* | ||
| * 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.spark.network.shuffle.protocol; | ||
|
|
||
| import java.util.*; | ||
|
|
||
| import com.google.common.base.Objects; | ||
| import io.netty.buffer.ByteBuf; | ||
|
|
||
| import org.apache.spark.network.protocol.Encoders; | ||
|
|
||
| // Needed by ScalaDoc. See SPARK-7726 | ||
attilapiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| import static org.apache.spark.network.shuffle.protocol.BlockTransferMessage.Type; | ||
|
|
||
| /** The reply to get local dirs giving back the dirs for each of the requested executors. */ | ||
| public class LocalDirsForExecutors extends BlockTransferMessage { | ||
| private final String[] execIds; | ||
| private final int[] numLocalDirsByExec; | ||
| private final String[] allLocalDirs; | ||
|
|
||
| public LocalDirsForExecutors(Map<String, String[]> localDirsByExec) { | ||
| this.execIds = new String[localDirsByExec.size()]; | ||
| this.numLocalDirsByExec = new int[localDirsByExec.size()]; | ||
| ArrayList<String> localDirs = new ArrayList<>(); | ||
| int index = 0; | ||
| for (Map.Entry<String, String[]> e: localDirsByExec.entrySet()) { | ||
| execIds[index] = e.getKey(); | ||
| numLocalDirsByExec[index] = e.getValue().length; | ||
| Collections.addAll(localDirs, e.getValue()); | ||
| index++; | ||
| } | ||
| this.allLocalDirs = localDirs.toArray(new String[0]); | ||
attilapiros marked this conversation as resolved.
Show resolved
Hide resolved
|
||
| } | ||
|
|
||
| private LocalDirsForExecutors(String[] execIds, int[] numLocalDirsByExec, String[] allLocalDirs) { | ||
| this.execIds = execIds; | ||
| this.numLocalDirsByExec = numLocalDirsByExec; | ||
| this.allLocalDirs = allLocalDirs; | ||
| } | ||
|
|
||
| @Override | ||
| protected Type type() { return Type.LOCAL_DIRS_FOR_EXECUTORS; } | ||
|
|
||
| @Override | ||
| public int hashCode() { | ||
| return Arrays.hashCode(execIds); | ||
| } | ||
|
|
||
| @Override | ||
| public String toString() { | ||
| return Objects.toStringHelper(this) | ||
| .add("execIds", Arrays.toString(execIds)) | ||
| .add("numLocalDirsByExec", Arrays.toString(numLocalDirsByExec)) | ||
| .add("allLocalDirs", Arrays.toString(allLocalDirs)) | ||
| .toString(); | ||
| } | ||
|
|
||
| @Override | ||
| public boolean equals(Object other) { | ||
| if (other instanceof LocalDirsForExecutors) { | ||
| LocalDirsForExecutors o = (LocalDirsForExecutors) other; | ||
| return Arrays.equals(execIds, o.execIds) | ||
| && Arrays.equals(numLocalDirsByExec, o.numLocalDirsByExec) | ||
| && Arrays.equals(allLocalDirs, o.allLocalDirs); | ||
| } | ||
| return false; | ||
| } | ||
|
|
||
| @Override | ||
| public int encodedLength() { | ||
| return Encoders.StringArrays.encodedLength(execIds) | ||
| + Encoders.IntArrays.encodedLength(numLocalDirsByExec) | ||
| + Encoders.StringArrays.encodedLength(allLocalDirs); | ||
| } | ||
|
|
||
| @Override | ||
| public void encode(ByteBuf buf) { | ||
| Encoders.StringArrays.encode(buf, execIds); | ||
| Encoders.IntArrays.encode(buf, numLocalDirsByExec); | ||
| Encoders.StringArrays.encode(buf, allLocalDirs); | ||
| } | ||
|
|
||
| public static LocalDirsForExecutors decode(ByteBuf buf) { | ||
| String[] execIds = Encoders.StringArrays.decode(buf); | ||
| int[] numLocalDirsByExec = Encoders.IntArrays.decode(buf); | ||
| String[] allLocalDirs = Encoders.StringArrays.decode(buf); | ||
| return new LocalDirsForExecutors(execIds, numLocalDirsByExec, allLocalDirs); | ||
| } | ||
|
|
||
| public Map<String, String[]> getLocalDirsByExec() { | ||
| Map<String, String[]> localDirsByExec = new HashMap<>(); | ||
| int index = 0; | ||
| int localDirsIndex = 0; | ||
| for (int length: numLocalDirsByExec) { | ||
| localDirsByExec.put(execIds[index], | ||
| Arrays.copyOfRange(allLocalDirs, localDirsIndex, localDirsIndex + length)); | ||
| localDirsIndex += length; | ||
| index++; | ||
| } | ||
| return localDirsByExec; | ||
| } | ||
| } | ||
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.
Uh oh!
There was an error while loading. Please reload this page.