-
Notifications
You must be signed in to change notification settings - Fork 230
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Move ProxyShuffleInternalManagerBase to api [databricks] (#9506)
This PR is taken from #9444 to separate the aspect of moving ProxyShuffleInternalManagerBase to the sql-plugin-api module - moves ProxyShuffleInternalManagerBase to sql-plugin-api module along with the required dependencies including ShimLoader - Adds dbdeps profile to sql-plugin-api because we now have to depend on spark classes in the API module as well - Leave the parts of ShimLoader that cannot be moved now as ShimLoaderTemp Signed-off-by: Gera Shegalov <gera@apache.org>
- Loading branch information
1 parent
bdc563e
commit 93c03e8
Showing
25 changed files
with
224 additions
and
202 deletions.
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
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
File renamed without changes.
93 changes: 93 additions & 0 deletions
93
...pi/src/main/scala/org/apache/spark/sql/rapids/ProxyRapidsShuffleInternalManagerBase.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,93 @@ | ||
/* | ||
* Copyright (c) 2023, NVIDIA CORPORATION. | ||
* | ||
* Licensed 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.sql.rapids | ||
|
||
import com.nvidia.spark.rapids.ShimLoader | ||
|
||
import org.apache.spark.{ShuffleDependency, SparkConf, TaskContext} | ||
import org.apache.spark.shuffle._ | ||
|
||
|
||
/** | ||
* Trait that makes it easy to check whether we are dealing with the | ||
* a RAPIDS Shuffle Manager | ||
*/ | ||
trait RapidsShuffleManagerLike { | ||
def isDriver: Boolean | ||
def initialize: Unit | ||
} | ||
|
||
/** | ||
* A simple proxy wrapper allowing to delay loading of the | ||
* real implementation to a later point when ShimLoader | ||
* has already updated Spark classloaders. | ||
* | ||
* @param conf | ||
* @param isDriver | ||
*/ | ||
class ProxyRapidsShuffleInternalManagerBase( | ||
conf: SparkConf, | ||
override val isDriver: Boolean | ||
) extends RapidsShuffleManagerLike with Proxy { | ||
|
||
// touched in the plugin code after the shim initialization | ||
// is complete | ||
lazy val self: ShuffleManager = ShimLoader.newInternalShuffleManager(conf, isDriver) | ||
.asInstanceOf[ShuffleManager] | ||
|
||
// This function touches the lazy val `self` so we actually instantiate | ||
// the manager. This is called from both the driver and executor. | ||
// In the driver, it's mostly to display information on how to enable/disable the manager, | ||
// in the executor, the UCXShuffleTransport starts and allocates memory at this time. | ||
override def initialize: Unit = self | ||
|
||
def getWriter[K, V]( | ||
handle: ShuffleHandle, | ||
mapId: Long, | ||
context: TaskContext, | ||
metrics: ShuffleWriteMetricsReporter | ||
): ShuffleWriter[K, V] = { | ||
self.getWriter(handle, mapId, context, metrics) | ||
} | ||
|
||
def getReader[K, C]( | ||
handle: ShuffleHandle, | ||
startMapIndex: Int, | ||
endMapIndex: Int, | ||
startPartition: Int, | ||
endPartition: Int, | ||
context: TaskContext, | ||
metrics: ShuffleReadMetricsReporter): ShuffleReader[K, C] = { | ||
self.getReader(handle, | ||
startMapIndex, endMapIndex, startPartition, endPartition, | ||
context, metrics) | ||
} | ||
|
||
def registerShuffle[K, V, C]( | ||
shuffleId: Int, | ||
dependency: ShuffleDependency[K, V, C] | ||
): ShuffleHandle = { | ||
self.registerShuffle(shuffleId, dependency) | ||
} | ||
|
||
def unregisterShuffle(shuffleId: Int): Boolean = self.unregisterShuffle(shuffleId) | ||
|
||
def shuffleBlockResolver: ShuffleBlockResolver = self.shuffleBlockResolver | ||
|
||
def stop(): Unit = self.stop() | ||
} | ||
|
File renamed without changes.
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.