LantaoJin commented on a change in pull request #23951: 
[SPARK-27038][CORE][YARN] Rack resolving takes a long time when initializing 
TaskSetManager
URL: https://github.com/apache/spark/pull/23951#discussion_r263318519
 
 

 ##########
 File path: 
resource-managers/yarn/src/main/scala/org/apache/spark/scheduler/cluster/YarnRackResolver.scala
 ##########
 @@ -0,0 +1,94 @@
+/*
+ * 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.scheduler.cluster
+
+import scala.collection.JavaConverters._
+import scala.collection.mutable.ArrayBuffer
+
+import com.google.common.base.Strings
+import org.apache.hadoop.conf.Configuration
+import org.apache.hadoop.fs.CommonConfigurationKeysPublic
+import org.apache.hadoop.net._
+import org.apache.hadoop.util.ReflectionUtils
+
+import org.apache.spark.internal.Logging
+
+/**
+ * Added in SPARK-27038. Before using the higher Hadoop version which applied 
YARN-9332,
+ * we construct [[YarnRackResolver]] instead of 
[[org.apache.hadoop.yarn.util.RackResolver]]
+ * to revolve the rack info.
+ */
+object YarnRackResolver extends Logging {
+  private var dnsToSwitchMapping: DNSToSwitchMapping = _
+  private var initCalled = false
+  // advisory count of arguments for rack script
+  private val ADVISORY_MINIMUM_NUMBER_SCRIPT_ARGS = 10000
+
+  def init(conf: Configuration): Unit = {
+    if (!initCalled) {
+      initCalled = true
+      val dnsToSwitchMappingClass =
+        
conf.getClass(CommonConfigurationKeysPublic.NET_TOPOLOGY_NODE_SWITCH_MAPPING_IMPL_KEY,
+          classOf[ScriptBasedMapping], classOf[DNSToSwitchMapping])
+      if 
(classOf[ScriptBasedMapping].isAssignableFrom(dnsToSwitchMappingClass)) {
+        val numArgs = 
conf.getInt(CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_NUMBER_ARGS_KEY,
+          
CommonConfigurationKeysPublic.NET_TOPOLOGY_SCRIPT_NUMBER_ARGS_DEFAULT)
+        if (numArgs < ADVISORY_MINIMUM_NUMBER_SCRIPT_ARGS) {
 
 Review comment:
   This is the max allowed count of script arguments in one execution. In 
Hadoop, the length of script arguments over `numArgs` will be executed in next 
round in loop. The default value 100 means hosts over 100 couldn't be resolved 
in one shot. For instance, we have 201 hosts to be resolved for a job, Hadoop 
will launch script three times to resolve:
   
   > script.py host1 host2 ... host100
   > script.py host101... host200, host201
   > script.py host201
   
   It launches this python script 3 times. First is for host1 to host100, the 
second round resolves host100 to host200, the last round only resolves host201.
   
   For Spark, in a big cluster, we hope to reduce the script execution rounds. 
100 may be too small. In a small cluster or small job, whatever this value is 
100 or 10000, there is no harm. But in for a large cluster with a big job. 
Logging out this warning log is to remind users to increase the configuration 
`net.topology.script.number.args` to reduce the inefficient execution loops of 
script.

----------------------------------------------------------------
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.
 
For queries about this service, please contact Infrastructure at:
[email protected]


With regards,
Apache Git Services

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to