Github user mridulm commented on a diff in the pull request: https://github.com/apache/spark/pull/17276#discussion_r108052753 --- Diff: core/src/main/java/org/apache/spark/shuffle/sort/BypassMergeSortShuffleWriter.java --- @@ -169,6 +173,36 @@ public void write(Iterator<Product2<K, V>> records) throws IOException { } } mapStatus = MapStatus$.MODULE$.apply(blockManager.shuffleServerId(), partitionLengths); + if (mapStatus instanceof HighlyCompressedMapStatus) { + HighlyCompressedMapStatus hc = (HighlyCompressedMapStatus) mapStatus; + long underestimatedBlocksSize = 0L; + for (int i = 0; i < partitionLengths.length; i++) { + if (partitionLengths[i] > mapStatus.getSizeForBlock(i)) { + underestimatedBlocksSize += partitionLengths[i]; + } + } + writeMetrics.incUnderestimatedBlocksSize(underestimatedBlocksSize); + if (logger.isDebugEnabled() && partitionLengths.length > 0) { + int underestimatedBlocksNum = 0; + // Distribution of sizes in MapStatus. + double[] cp = new double[partitionLengths.length]; + for (int i = 0; i < partitionLengths.length; i++) { + cp[i] = partitionLengths[i]; + if (partitionLengths[i] > mapStatus.getSizeForBlock(i)) { + underestimatedBlocksNum++; + } + } + Distribution distribution = new Distribution(cp, 0, cp.length); + double[] probabilities = {0.0, 0.25, 0.5, 0.75, 1.0}; + String distributionStr = distribution.getQuantiles(probabilities).mkString(", "); + logger.debug("For task {}.{} in stage {} (TID {}), the block sizes in MapStatus are " + + "inaccurate (average is {}, {} blocks underestimated, size of underestimated is {})," + + " distribution at the given probabilities(0, 0.25, 0.5, 0.75, 1.0) is {}.", + taskContext.partitionId(), taskContext.attemptNumber(), taskContext.stageId(), + taskContext.taskAttemptId(), hc.getAvgSize(), + underestimatedBlocksNum, underestimatedBlocksSize, distributionStr); + } + } --- End diff -- We need to handle case of mapStatus not being HighlyCompressedMapStatus also.
--- If your project is set up for it, you can reply to this email and have your reply appear on GitHub as well. If your project does not have this feature enabled and wishes so, or if the feature is enabled but not working, please contact infrastructure at infrastruct...@apache.org or file a JIRA ticket with INFRA. --- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org