tgravescs commented on a change in pull request #25907: [SPARK-29206][SHUFFLE] 
Make number of shuffle server threads a multiple of number of chunk fetch 
handler threads.
URL: https://github.com/apache/spark/pull/25907#discussion_r328346113
 
 

 ##########
 File path: 
common/network-common/src/main/java/org/apache/spark/network/util/TransportConf.java
 ##########
 @@ -111,8 +111,30 @@ public int numConnectionsPerPeer() {
   /** Requested maximum length of the queue of incoming connections. Default 
is 64. */
   public int backLog() { return conf.getInt(SPARK_NETWORK_IO_BACKLOG_KEY, 64); 
}
 
-  /** Number of threads used in the server thread pool. Default to 0, which is 
2x#cores. */
-  public int serverThreads() { return 
conf.getInt(SPARK_NETWORK_IO_SERVERTHREADS_KEY, 0); }
+  /**
+   * The configured ratio between number of server threads and number of chunk 
fetch handler
+   * threads. Default to 1, which sets the size of both thread pools to be 
equal. Number of
+   * server threads needs to be a multiple of this ratio. See SPARK-29206.
+   */
+  private int getChunkFetchHandlerThreadsRatio() {
+    return conf.getInt("spark.shuffle.server.chunkFetchHandlerThreadsRatio", 
1);
+  }
+
+  /**
+   * Number of threads used in the server thread pool. Default to 0, which is 
2x#cores.
+   * If spark.shuffle.server.chunkFetchHandlerThreadsRatio is configured, and 
the Netty server
+   * is for shuffle, then the actual # of server threads will round up to the 
nearest int that
+   * is a multiple of the configured ratio.
+   */
+  public int serverThreads() {
+    int configuredServerThreads = 
conf.getInt(SPARK_NETWORK_IO_SERVERTHREADS_KEY, 0);
+    if (this.getModuleName().equalsIgnoreCase("shuffle")) {
+      int chunkFetchHandlerThreadsRatio = getChunkFetchHandlerThreadsRatio();
+      return (int) Math.ceil(configuredServerThreads / 
(chunkFetchHandlerThreadsRatio * 1.0));
 
 Review comment:
   right the server threads stay 0 but the chunk fetcher threads stays 0 as 
well, that is different than the previous config, which would still take 
2*availablecores * chunkFetchHandlerThreadsPercent/100.
   so this requires you to set server threads for the config to work whereas 
previously it didn't. I would like to keep the behavior of it applying even if 
don't explicitly set server threads.
   
   the logic here also still seems wrong but maybe I'm still missing what your 
config is.
   
   I configure server threads to 10 and thread ratio to 2. 
   (int) Math.ceil(configuredServerThreads / (chunkFetchHandlerThreadsRatio * 
1.0)) = 5 server threads which is not close to what I set the config to (10).  
I would have expected server threads to stay 10 and the chunk fetch handler 
threads to be 5.  You are missing a multiply back by 
chunkFetchHandlerThreadsRatio.

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