zhztheplayer commented on code in PR #13115:
URL: https://github.com/apache/gluten/pull/13115#discussion_r4264831464


##########
gluten-core/src/main/scala/org/apache/spark/util/SparkResourceUtil.scala:
##########
@@ -75,6 +75,23 @@ object SparkResourceUtil extends Logging {
     cores
   }
 
+  // Mirrors org.apache.spark.SparkContext#numDriverCores: in local mode the 
driver and executor
+  // share the same JVM, so return the local-master thread count; otherwise 
fall back to
+  // spark.driver.cores with Spark's default of 1. spark.master may be absent 
on some call sites
+  // (e.g. unit tests that construct a bare SparkConf), so read it as an 
option.
+  def getDriverCores(conf: SparkConf): Int = {

Review Comment:
   ditto



##########
backends-velox/src/main/scala/org/apache/gluten/backendsapi/velox/VeloxListenerApi.scala:
##########
@@ -317,6 +317,18 @@ object VeloxListenerApi {
       parsed += (COLUMNAR_VELOX_CACHE_ENABLED.key -> "false")
     }
 
+    // The broadcast hash-table build thread pool is sized from 
numTaskSlotsPerExecutor by default,
+    // which is derived from executor cores. On the driver, this would 
misreport the available
+    // parallelism: driver-side hash-table build runs in the driver JVM and 
should be bounded by
+    // spark.driver.cores. Only override when the user has not pinned the 
thread count explicitly.
+    if (
+      isDriver && !inLocalMode(conf) &&
+      !parsed.contains(COLUMNAR_VELOX_BROADCAST_HASH_TABLE_BUILD_THREADS.key)
+    ) {
+      val driverCores = SparkResourceUtil.getDriverCores(conf)
+      parsed += (COLUMNAR_VELOX_BROADCAST_HASH_TABLE_BUILD_THREADS.key -> 
driverCores.toString)
+    }

Review Comment:
   This driver core detection code looks sound to me but probably better to be 
placed to an independent PR? Which keeps this PR only scoped for the pool 
change?



-- 
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]

Reply via email to