You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@auron.apache.org by "cxzl25 (via GitHub)" <gi...@apache.org> on 2025/09/02 06:04:50 UTC
[PR] support HDFS CallerContext [auron]
cxzl25 opened a new pull request, #1260:
URL: https://github.com/apache/auron/pull/1260
# Which issue does this PR close?
Closes #.
# Rationale for this change
# What changes are included in this PR?
1. jni fs read and write threads set thread names for easy tracking
```
25/08/12 14:59:48,104 [Spark native task 2.0 in stage 3.0 (TID 6)] INFO DFSClient: Connecting to datanode x:y for file /ux for block x:y
```
2. jni fs read and write thread pass CallerContex, which can be traced in HDFS audit log
```
SPARK_TASK_application_x_y_JId_-1_SId_3_0_TId_6_0
```
# Are there any user-facing changes?
No
# How was this patch tested?
GA
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AURON-1272] Support HDFS CallerContext [auron]
Posted by "cxzl25 (via GitHub)" <gi...@apache.org>.
cxzl25 commented on PR #1260:
URL: https://github.com/apache/auron/pull/1260#issuecomment-3257287896
> Shell we create an issue to track this change and update the PR title accordingly?
DONE AURON-1272
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "richox (via GitHub)" <gi...@apache.org>.
richox commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2317626350
##########
spark-extension/src/main/java/org/apache/spark/sql/auron/JniBridge.java:
##########
@@ -89,10 +90,14 @@ public static boolean isDriverSide() {
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
// the path is a URI string, so we need to convert it to a URI object, ref:
// org.apache.spark.paths.SparkPath.toPath
+ TaskContextHelper$.MODULE$.setThreadNameFromTaskContext();
Review Comment:
i suggest adding a static method `JniBridge.initNativeThread` to do all this initialization for reducing number of JNI calls.
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "richox (via GitHub)" <gi...@apache.org>.
richox commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2317629049
##########
spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala:
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.sql.auron.util
+
+import scala.util.control.NonFatal
+
+import org.apache.spark.{SparkEnv, TaskContext}
+import org.apache.spark.deploy.SparkHadoopUtil
+import org.apache.spark.internal.Logging
+import org.apache.spark.internal.config.APP_CALLER_CONTEXT
+import org.apache.spark.util.Utils
+
+object TaskContextHelper extends Logging {
+
+ private val callerContextSupported: Boolean = {
+ SparkHadoopUtil.get.conf.getBoolean("hadoop.caller.context.enabled", false) && {
+ try {
+ Utils.classForName("org.apache.hadoop.ipc.CallerContext")
+ Utils.classForName("org.apache.hadoop.ipc.CallerContext$Builder")
+ true
+ } catch {
+ case _: ClassNotFoundException =>
+ false
+ case NonFatal(e) =>
+ logWarning("Fail to load the CallerContext class", e)
+ false
+ }
+ }
+ }
+
+ def setThreadNameFromTaskContext(): Unit = {
+ val context: TaskContext = TaskContext.get()
+ if (context != null) {
+ val threadName =
+ s"Spark native task ${context.partitionId()}.${context.attemptNumber()} in stage ${context
Review Comment:
yes, a name like `auron-task-<partitionid>-<taskid>` is better, in the future we'd like to support more engines than spark.
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] [AURON-1272] Support HDFS CallerContext [auron]
Posted by "richox (via GitHub)" <gi...@apache.org>.
richox merged PR #1260:
URL: https://github.com/apache/auron/pull/1260
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2315829555
##########
spark-extension/src/main/java/org/apache/spark/sql/auron/JniBridge.java:
##########
@@ -89,10 +90,14 @@ public static boolean isDriverSide() {
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
// the path is a URI string, so we need to convert it to a URI object, ref:
// org.apache.spark.paths.SparkPath.toPath
+ TaskContextHelper$.MODULE$.setThreadNameFromTaskContext();
Review Comment:
Can we set jvm thread name in `tokio_runtime_builder.on_thread_start`?
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2315836684
##########
spark-extension/src/main/java/org/apache/spark/sql/auron/JniBridge.java:
##########
@@ -89,10 +90,14 @@ public static boolean isDriverSide() {
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
// the path is a URI string, so we need to convert it to a URI object, ref:
// org.apache.spark.paths.SparkPath.toPath
+ TaskContextHelper$.MODULE$.setThreadNameFromTaskContext();
+ TaskContextHelper$.MODULE$.setHDFSCallerContext();
Review Comment:
HDFS caller context also seems to be a threa local object, maybe we can initialize it in `tokio_runtime_builder.on_thread_start` .
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "ShreyeshArangath (via GitHub)" <gi...@apache.org>.
ShreyeshArangath commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2316790148
##########
spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala:
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.sql.auron.util
+
+import scala.util.control.NonFatal
+
+import org.apache.spark.{SparkEnv, TaskContext}
+import org.apache.spark.deploy.SparkHadoopUtil
+import org.apache.spark.internal.Logging
+import org.apache.spark.internal.config.APP_CALLER_CONTEXT
+import org.apache.spark.util.Utils
+
+object TaskContextHelper extends Logging {
+
+ private val callerContextSupported: Boolean = {
+ SparkHadoopUtil.get.conf.getBoolean("hadoop.caller.context.enabled", false) && {
+ try {
+ Utils.classForName("org.apache.hadoop.ipc.CallerContext")
+ Utils.classForName("org.apache.hadoop.ipc.CallerContext$Builder")
+ true
+ } catch {
+ case _: ClassNotFoundException =>
+ false
+ case NonFatal(e) =>
+ logWarning("Fail to load the CallerContext class", e)
+ false
+ }
+ }
+ }
+
+ def setThreadNameFromTaskContext(): Unit = {
+ val context: TaskContext = TaskContext.get()
+ if (context != null) {
+ val threadName =
+ s"Spark native task ${context.partitionId()}.${context.attemptNumber()} in stage ${context
Review Comment:
`Spark native task` seems a little ambiguous, any reason for not using Auron here?
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2317683532
##########
spark-extension/src/main/java/org/apache/spark/sql/auron/JniBridge.java:
##########
@@ -89,10 +90,14 @@ public static boolean isDriverSide() {
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
// the path is a URI string, so we need to convert it to a URI object, ref:
// org.apache.spark.paths.SparkPath.toPath
+ TaskContextHelper$.MODULE$.setThreadNameFromTaskContext();
Review Comment:
> i suggest adding a static method `JniBridge.initNativeThread` to do all this initialization for reducing number of JNI calls.
Sounds good
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2315829555
##########
spark-extension/src/main/java/org/apache/spark/sql/auron/JniBridge.java:
##########
@@ -89,10 +90,14 @@ public static boolean isDriverSide() {
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
// the path is a URI string, so we need to convert it to a URI object, ref:
// org.apache.spark.paths.SparkPath.toPath
+ TaskContextHelper$.MODULE$.setThreadNameFromTaskContext();
Review Comment:
Can we set jvm thread name in `tokio_runtime_builder.on_thread_start`?
https://github.com/apache/auron/blob/1dc88d23347955288ece7cb12edba2a48051bf7a/native-engine/auron/src/rt.rs#L115-L125
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2315836684
##########
spark-extension/src/main/java/org/apache/spark/sql/auron/JniBridge.java:
##########
@@ -89,10 +90,14 @@ public static boolean isDriverSide() {
public static FSDataInputWrapper openFileAsDataInputWrapper(FileSystem fs, String path) throws Exception {
// the path is a URI string, so we need to convert it to a URI object, ref:
// org.apache.spark.paths.SparkPath.toPath
+ TaskContextHelper$.MODULE$.setThreadNameFromTaskContext();
+ TaskContextHelper$.MODULE$.setHDFSCallerContext();
Review Comment:
HDFS caller context also seems to be a thread local object, maybe we can initialize it in `tokio_runtime_builder.on_thread_start` .
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "richox (via GitHub)" <gi...@apache.org>.
richox commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2321406802
##########
spark-extension/src/main/scala/org/apache/spark/sql/auron/util/TaskContextHelper.scala:
##########
@@ -0,0 +1,133 @@
+/*
+ * 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.sql.auron.util
+
+import scala.util.control.NonFatal
+
+import org.apache.spark.{SparkEnv, TaskContext}
+import org.apache.spark.deploy.SparkHadoopUtil
+import org.apache.spark.internal.Logging
+import org.apache.spark.internal.config.APP_CALLER_CONTEXT
+import org.apache.spark.util.Utils
+
+object TaskContextHelper extends Logging {
+
+ private val callerContextSupported: Boolean = {
+ SparkHadoopUtil.get.conf.getBoolean("hadoop.caller.context.enabled", false) && {
+ try {
+ Utils.classForName("org.apache.hadoop.ipc.CallerContext")
+ Utils.classForName("org.apache.hadoop.ipc.CallerContext$Builder")
+ true
+ } catch {
+ case _: ClassNotFoundException =>
+ false
+ case NonFatal(e) =>
+ logWarning("Fail to load the CallerContext class", e)
+ false
+ }
+ }
+ }
+
+ def setThreadNameFromTaskContext(): Unit = {
+ val context: TaskContext = TaskContext.get()
+ if (context != null) {
+ val threadName =
+ s"auron native task ${context.partitionId()}.${context.attemptNumber()} in stage ${context
+ .stageId()}.${context.stageAttemptNumber()} (TID ${context.taskAttemptId()})"
+ Thread.currentThread().setName(threadName)
+ }
Review Comment:
we should have an else branch to handle driver side native threads (for building BHJ hash table).
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "wForget (via GitHub)" <gi...@apache.org>.
wForget commented on code in PR #1260:
URL: https://github.com/apache/auron/pull/1260#discussion_r2320627613
##########
native-engine/auron/src/rt.rs:
##########
@@ -120,6 +120,9 @@ impl NativeExecutionRuntime {
let _ = jni_call_static!(
JniBridge.setTaskContext(spark_task_context_global.as_obj()) -> ()
);
+ let _ = jni_call_static!(
+ JniBridge.initNativeThread() -> ()
Review Comment:
Should we also use this method to set `classloader` and `spark_task_context` to reduce jni calls? cc @richox
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
Re: [PR] support HDFS CallerContext [auron]
Posted by "merrily01 (via GitHub)" <gi...@apache.org>.
merrily01 commented on PR #1260:
URL: https://github.com/apache/auron/pull/1260#issuecomment-3252132270
Looks good, except minor comments.
Shell we create an issue to track this change and update the PR title accordingly?
--
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: commits-unsubscribe@auron.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org