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


##########
cpp/velox/compute/VeloxBackend.cc:
##########
@@ -254,6 +255,10 @@ void VeloxBackend::init(
         std::make_unique<folly::CPUThreadPoolExecutor>(ioThreads, 
folly::CPUThreadPoolExecutor::makeLifoSemQueue());
   }
 
+  const auto broadcastHashTableBuildThreads =
+      std::max<int32_t>(1, 
backendConf_->get<int32_t>(kBroadcastHashTableBuildThreads, 
numTaskSlotsPerExecutor));
+  broadcastHashTableBuildExecutor_ = 
std::make_unique<folly::CPUThreadPoolExecutor>(broadcastHashTableBuildThreads);

Review Comment:
   The PR description says this follows the existing `getReaderThreadPool()` 
`std::call_once` pattern, but the executor is created eagerly during `init()` 
here. If the intent is to match that pattern (and avoid starting extra threads 
when parallel broadcast build is never used), consider lazy-initializing this 
executor with `std::call_once`/on-demand creation. Otherwise, please update the 
PR description to reflect the eager initialization behavior.



##########
gluten-ut/spark35/src/test/backends-velox/org/apache/spark/sql/execution/joins/GlutenParallelBroadcastJoinSuite.scala:
##########
@@ -0,0 +1,65 @@
+/*
+ * 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.execution.joins
+
+import org.apache.gluten.execution.BroadcastHashJoinExecTransformer
+
+import org.apache.spark.SparkConf
+import org.apache.spark.sql.GlutenSQLTestsTrait
+import org.apache.spark.sql.execution.ColumnarBroadcastExchangeExec
+
+class GlutenParallelBroadcastJoinSuite extends GlutenSQLTestsTrait {
+
+  override def sparkConf: SparkConf = super.sparkConf
+    .set("spark.sql.adaptive.enabled", "false")
+    .set("spark.gluten.sql.columnar.backend.velox.IOThreads", "0")
+    .set("spark.gluten.velox.broadcast.build.targetBytesPerThread", "8KB")
+
+  for (buildOnDriver <- Seq(false, true)) {
+    testGluten(s"parallel broadcast hash table build with IO disabled, 
driver=$buildOnDriver") {
+      withSQLConf(
+        
"spark.gluten.sql.columnar.backend.velox.driverSideBroadcastHashTableBuild" ->
+          buildOnDriver.toString,
+        "spark.gluten.velox.minTableRowsForParallelJoinBuild" -> "1",
+        
"spark.gluten.sql.columnar.backend.velox.broadcastHashTableBuildThreads" -> "4"

Review Comment:
   In this PR, `broadcastHashTableBuildThreads` is registered via 
`buildStaticConf(...)` (static). Spark typically disallows changing static SQL 
configs via `withSQLConf` after the session is created, which can make this 
test flaky or fail. Prefer setting this key in the suite-level `sparkConf` 
(before session creation) or constructing a session scoped to this test with 
the desired `SparkConf`.



##########
cpp/velox/jni/VeloxJniWrapper.cc:
##########
@@ -1138,7 +1138,7 @@ JNIEXPORT jlong JNICALL 
Java_org_apache_gluten_vectorized_HashJoinBuilder_native
       facebook::velox::exec::BaseHashTable::kNoSpillInputStartPartitionBit,
       hashTableBuilders[0]->joinBuildVectorHasherMaxNumDistinct(),
       hashTableBuilders[0]->dropDuplicates(),
-      allowParallelJoinBuild ? VeloxBackend::get()->ioExecutor() : nullptr);
+      allowParallelJoinBuild ? 
VeloxBackend::get()->broadcastHashTableBuildExecutor() : nullptr);

Review Comment:
   This call fetches `broadcastHashTableBuildExecutor()` again even though an 
`executor` variable is already created earlier in the function for the same 
purpose. Reusing the existing local `executor` avoids duplication and 
guarantees the same executor instance is used consistently within the method.



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