Github user mridulm commented on a diff in the pull request:

    https://github.com/apache/spark/pull/17276#discussion_r108052758
  
    --- Diff: 
core/src/main/java/org/apache/spark/shuffle/sort/UnsafeShuffleWriter.java ---
    @@ -228,6 +230,36 @@ void closeAndWriteOutput() 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 --
    
    This computation seems repeated - we should refactor it out into a method 
of its own and not duplicate it across classes.


---
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 [email protected] or file a JIRA ticket
with INFRA.
---

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

Reply via email to