wankunde commented on a change in pull request #34234:
URL: https://github.com/apache/spark/pull/34234#discussion_r733679745



##########
File path: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala
##########
@@ -255,9 +255,24 @@ private[spark] object HighlyCompressedMapStatus {
     // we expect that there will be far fewer of them, so we will perform 
fewer bitmap insertions.
     val emptyBlocks = new RoaringBitmap()
     val totalNumBlocks = uncompressedSizes.length
-    val threshold = Option(SparkEnv.get)
-      .map(_.conf.get(config.SHUFFLE_ACCURATE_BLOCK_THRESHOLD))
-      .getOrElse(config.SHUFFLE_ACCURATE_BLOCK_THRESHOLD.defaultValue.get)
+    val medianSize: Long = {
+      val sortedSizes = uncompressedSizes.sorted

Review comment:
       I don't think  the sort of thousands of number will cost too much ? Am i 
right ?

##########
File path: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala
##########
@@ -255,9 +255,24 @@ private[spark] object HighlyCompressedMapStatus {
     // we expect that there will be far fewer of them, so we will perform 
fewer bitmap insertions.
     val emptyBlocks = new RoaringBitmap()
     val totalNumBlocks = uncompressedSizes.length
-    val threshold = Option(SparkEnv.get)
-      .map(_.conf.get(config.SHUFFLE_ACCURATE_BLOCK_THRESHOLD))
-      .getOrElse(config.SHUFFLE_ACCURATE_BLOCK_THRESHOLD.defaultValue.get)
+    val medianSize: Long = {
+      val sortedSizes = uncompressedSizes.sorted
+      if (totalNumBlocks % 2 == 0) {
+        Math.max((sortedSizes(totalNumBlocks / 2) + sortedSizes(totalNumBlocks 
/ 2 - 1)) / 2, 1)
+      } else {
+        Math.max(sortedSizes(totalNumBlocks / 2), 1)
+      }
+    }
+    val skewSizeThreshold =
+      medianSize * Option(SparkEnv.get)
+        .map(_.conf.get(config.SHUFFLE_ACCURATE_BLOCK_SKEWED_FACTOR))
+        
.getOrElse(config.SHUFFLE_ACCURATE_BLOCK_SKEWED_FACTOR.defaultValue.get)

Review comment:
       There are many long running skewed jobs in our cluster, but the driver 
does not recognize the skewed tasks.
   For example, the job in the PR description.




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