PHILO-HE commented on code in PR #9150:
URL: https://github.com/apache/incubator-gluten/pull/9150#discussion_r2022440343
##########
backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxListenerApi.scala:
##########
@@ -142,13 +142,19 @@ class VeloxListenerApi extends ListenerApi with Logging {
}
SparkDirectoryUtil.init(conf)
- UDFResolver.resolveUdfConf(conf, isDriver = false)
initialize(conf, isDriver = false)
}
override def onExecutorShutdown(): Unit = shutdown()
private def initialize(conf: SparkConf, isDriver: Boolean): Unit = {
+ JniWorkspace.initializeDefault(
+ SparkDirectoryUtil.get
+ .namespace("jni")
+ .mkChildDirRandomly(UUID.randomUUID.toString)
+ .getAbsolutePath)
Review Comment:
Compared with the original code, one difference is making dir is outside the
synchronized block, which can cause extra directory unnecessarily created.
Maybe, we can pass the making dir function as argument to initializeDefault and
let the dir be created inside initializeDefault.
##########
gluten-core/src/main/java/org/apache/gluten/jni/JniWorkspace.java:
##########
@@ -99,12 +85,17 @@ public static void enableDebug(String debugDir) {
}
}
- public static JniWorkspace getDefault() {
+ public static void initializeDefault(String rootDir) {
synchronized (DEFAULT_INSTANCE_INIT_LOCK) {
if (DEFAULT_INSTANCE == null) {
- DEFAULT_INSTANCE = createDefault();
+ DEFAULT_INSTANCE = createOrGet(rootDir);
}
- Preconditions.checkNotNull(DEFAULT_INSTANCE);
+ }
+ }
+
+ public static JniWorkspace getDefault() {
+ synchronized (DEFAULT_INSTANCE_INIT_LOCK) {
Review Comment:
@shuai-xu, seems no need to add "synchronized" in getting the instance.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]