You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by rxin <gi...@git.apache.org> on 2014/09/20 10:22:30 UTC

[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

GitHub user rxin opened a pull request:

    https://github.com/apache/spark/pull/2470

    [SPARK-3613] Record only average block size in MapStatus for large stages

    This changes the way we send MapStatus from executors back to driver for large stages (>2000 tasks). For large stages, we no longer send one byte per block. Instead, we just send the average block size.
    
    This makes large jobs (tens of thousands of tasks) much more reliable since the driver no longer sends huge amount of data.

You can merge this pull request into a Git repository by running:

    $ git pull https://github.com/rxin/spark mapstatus

Alternatively you can review and apply these changes as the patch at:

    https://github.com/apache/spark/pull/2470.patch

To close this pull request, make a commit to your master/trunk branch
with (at least) the following in the commit message:

    This closes #2470
    
----
commit d139abe0850c671166b8cf260d6852c8aa7797e5
Author: Reynold Xin <rx...@apache.org>
Date:   2014-09-20T08:19:31Z

    [SPARK-3613] Record only average block size in MapStatus for large stages.

----


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57216500
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20991/consoleFull) for   PR 2470 at commit [`822ff54`](https://github.com/apache/spark/commit/822ff54ca2064b2f4fe9c836c1bb5991e5788bec).
     * This patch merges cleanly.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by Ishiihara <gi...@git.apache.org>.
Github user Ishiihara commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56310242
  
    @rxin @lemire Starting looking at Roaring.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57270302
  
    Merging in master.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57224538
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/20991/


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57041847
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/163/consoleFull) for   PR 2470 at commit [`d139abe`](https://github.com/apache/spark/commit/d139abe0850c671166b8cf260d6852c8aa7797e5).
     * This patch **fails** unit tests.
     * This patch merges cleanly.
     * This patch adds no public 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57041867
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20900/consoleFull) for   PR 2470 at commit [`11f5319`](https://github.com/apache/spark/commit/11f531961a3f37c91563fae93999e3f7baa98788).
     * This patch **fails** unit tests.
     * This patch merges cleanly.
     * This patch adds no public 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by Ishiihara <gi...@git.apache.org>.
Github user Ishiihara commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56292536
  
    @rxin I am definitely interested in working on adding compressed bitmap. What is the first step?  Thanks.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136257
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    --- End diff --
    
    yes. i really have no need for an accessor here


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57266700
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/206/consoleFull) for   PR 2470 at commit [`822ff54`](https://github.com/apache/spark/commit/822ff54ca2064b2f4fe9c836c1bb5991e5788bec).
     * This patch merges cleanly.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57270082
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/206/consoleFull) for   PR 2470 at commit [`822ff54`](https://github.com/apache/spark/commit/822ff54ca2064b2f4fe9c836c1bb5991e5788bec).
     * This patch **passes** unit tests.
     * This patch merges cleanly.
     * This patch adds no public 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57041868
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/20900/


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57038175
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20895/consoleFull) for   PR 2470 at commit [`d139abe`](https://github.com/apache/spark/commit/d139abe0850c671166b8cf260d6852c8aa7797e5).
     * This patch merges cleanly.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56277279
  
    It's more than that. We use estimated sizes to track the total size of outstanding fetches, and try to bound that to a certain size in case an executor sends too many requests and runs out of memory. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by asfgit <gi...@git.apache.org>.
Github user asfgit closed the pull request at:

    https://github.com/apache/spark/pull/2470


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57218350
  
    I'm glad it is P!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57043231
  
    Test PASSed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/20902/


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57038053
  
    test this please


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57217955
  
    Great, LPGTM


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136876
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    --- End diff --
    
    I'm going to add : Unit here, but for the sake of the argument:
    
    Yes - I actually personally followed that for a while (a lot of my code added : Unit to it). After I while, I actually found it very annoying because it happened to me multiple times that I had to line wrap because of the extra : Unit and then I stopped doing that. I absolutely don't buy the Scala style guide that not adding ": Unit" is confusing. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56292164
  
    It really depends on the number of zero-sized blocks. One thing we can possibly do is to create a compressed bitmap to track zero sized blocks, as discussed here: http://apache-spark-developers-list.1001551.n3.nabble.com/Eliminate-copy-while-sending-data-any-Akka-experts-here-td7127.html#a7146
    
    Maybe we can use the ewah by @lemire 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by lemire <gi...@git.apache.org>.
Github user lemire commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56372140
  
    @Ishiihara  Get in touch if you have questions.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56292398
  
    @lemire our requirements here are very simple. We just need to have a bitmap to track the position of zero-sized blocks in Spark shuffle. Things we need from the bitmap implementation are:
    
    1. Fast serialization / deserialization (if there is an byte array that we can write out directly, perfect)
    2. Fast sequential access (just give us the non-zero sized blocks one by one).
    
    So unlike databases, we don't need intersection. I saw that you have published a new archive paper on roaring bitmaps too. Which one would you recommend for this workload? 



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57039551
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20895/consoleFull) for   PR 2470 at commit [`d139abe`](https://github.com/apache/spark/commit/d139abe0850c671166b8cf260d6852c8aa7797e5).
     * This patch **fails** unit tests.
     * This patch merges cleanly.
     * This patch adds no public 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by markhamstra <gi...@git.apache.org>.
Github user markhamstra commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136843
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    --- End diff --
    
    Right, procedure syntax is now officially frowned upon in the Scala style guide, but we haven't formally adopted that position in the Spark style guide -- but we probably should. 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57224525
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20991/consoleFull) for   PR 2470 at commit [`822ff54`](https://github.com/apache/spark/commit/822ff54ca2064b2f4fe9c836c1bb5991e5788bec).
     * This patch **fails** unit tests.
     * This patch merges cleanly.
     * This patch adds no public 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by lemire <gi...@git.apache.org>.
Github user lemire commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56309772
  
    @rxin  We are currently working with the Druid.io guys to integrate Roaring (http://roaringbitmap.org). We get good results and even support memory mapped bitmaps (with ByteBuffer).
    
    At this point, I would recommend you try out roaring. I am available to help.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57270495
  
    I also filed a new jira for the compressed bitmap thing: https://issues.apache.org/jira/browse/SPARK-3740



---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by Ishiihara <gi...@git.apache.org>.
Github user Ishiihara commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57274044
  
    @rxin I looked through Roaring bitmap and that is a highly compressed bitmap compared with other bitmap implementations. I will start working on this and keep you updated with progress and issues coming up during implementation. Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57041883
  
    hm mima failed even though MapStatus is private[spark]. I will add an exclude.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57040529
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20900/consoleFull) for   PR 2470 at commit [`11f5319`](https://github.com/apache/spark/commit/11f531961a3f37c91563fae93999e3f7baa98788).
     * This patch merges cleanly.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57040450
  
    Jenkins, test this please.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18137292
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    --- End diff --
    
    Yeah, I don't buy that either. I think what's really confusing though is if a method doesn't return anything but looks like this:
    ```
    def eatFood(...) = {
      ...
    }
    ```
    If we always add `Unit` to the end we'll never have this problem.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57040503
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/NewSparkPullRequestBuilder/163/consoleFull) for   PR 2470 at commit [`d139abe`](https://github.com/apache/spark/commit/d139abe0850c671166b8cf260d6852c8aa7797e5).
     * This patch merges cleanly.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by AmplabJenkins <gi...@git.apache.org>.
Github user AmplabJenkins commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57039553
  
    Test FAILed.
    Refer to this link for build results (access rights to CI server needed): 
    https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/20895/


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57043227
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20902/consoleFull) for   PR 2470 at commit [`f7e720a`](https://github.com/apache/spark/commit/f7e720aa93f348c20f8f9067ddba98550256e515).
     * This patch **passes** unit tests.
     * This patch merges cleanly.
     * This patch adds no public 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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56292244
  
    @Ishiihara let me know if you are interested in working on adding compressed bitmap to this.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by Ishiihara <gi...@git.apache.org>.
Github user Ishiihara commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56277955
  
    Thanks for the reply. Another questions, In hash shuffle write, the data may be screwed for different map output file. For some cases, the reducer may try to fetch many files which does not contain its data. What is the overhead does this introduces? 


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by Ishiihara <gi...@git.apache.org>.
Github user Ishiihara commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-56277206
  
    @rxin my understanding is that MapStatus is used to check whether a map output file contain data for a certain reducer. Why do we use actual size instead of a boolean flag? Thanks!


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by rxin <gi...@git.apache.org>.
Github user rxin commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136384
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    --- End diff --
    
    Do we have a rule for that?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136256
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    +    loc = BlockManagerId(in)
    +    val len = in.readInt()
    +    compressedSizes = new Array[Byte](len)
         in.readFully(compressedSizes)
       }
     }
    +
    +
    +/**
    + * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + *
    + * @param loc location where the task is being executed.
    + * @param avgSize average size of all the blocks
    + */
    +private[spark] class LargeMapStatus(
    --- End diff --
    
    `LargeMapStatus` sounds like the map status itself is large, but really this is a small map status right? How about something like `AverageSizeMapStatus` or whatever better name you can come up with?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136211
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    --- End diff --
    
    Why private this? Is this for performance reasons?


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136738
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    --- End diff --
    
    I don't think it's written anywhere, but many of us have been doing it. (See "Procedure Syntax" http://docs.scala-lang.org/style/declarations.html)


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by andrewor14 <gi...@git.apache.org>.
Github user andrewor14 commented on a diff in the pull request:

    https://github.com/apache/spark/pull/2470#discussion_r18136349
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -24,22 +24,123 @@ import org.apache.spark.storage.BlockManagerId
     /**
      * Result returned by a ShuffleMapTask to a scheduler. Includes the block manager address that the
      * task ran on as well as the sizes of outputs for each reducer, for passing on to the reduce tasks.
    - * The map output sizes are compressed using MapOutputTracker.compressSize.
      */
    -private[spark] class MapStatus(var location: BlockManagerId, var compressedSizes: Array[Byte])
    -  extends Externalizable {
    +private[spark] sealed trait MapStatus {
    +  /** Location where this task was run. */
    +  def location: BlockManagerId
     
    -  def this() = this(null, null)  // For deserialization only
    +  /** Estimated size for the reduce block. */
    +  def getSizeForBlock(reduceId: Int): Long
    +}
    +
    +
    +private[spark] object MapStatus {
    +
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): MapStatus = {
    +    if (uncompressedSizes.length > 2000) {
    +      new LargeMapStatus(loc, uncompressedSizes)
    +    } else {
    +      new DetailedMapStatus(loc, uncompressedSizes)
    +    }
    +  }
    +
    +  private[this] val LOG_BASE = 1.1
    +
    +  /**
    +   * Compress a size in bytes to 8 bits for efficient reporting of map output sizes.
    +   * We do this by encoding the log base 1.1 of the size as an integer, which can support
    +   * sizes up to 35 GB with at most 10% error.
    +   */
    +  def compressSize(size: Long): Byte = {
    +    if (size == 0) {
    +      0
    +    } else if (size <= 1L) {
    +      1
    +    } else {
    +      math.min(255, math.ceil(math.log(size) / math.log(LOG_BASE)).toInt).toByte
    +    }
    +  }
    +
    +  /**
    +   * Decompress an 8-bit encoded block size, using the reverse operation of compressSize.
    +   */
    +  def decompressSize(compressedSize: Byte): Long = {
    +    if (compressedSize == 0) {
    +      0
    +    } else {
    +      math.pow(LOG_BASE, compressedSize & 0xFF).toLong
    +    }
    +  }
    +}
    +
    +
    +/**
    + * A [[MapStatus]] implementation that tracks the size of each block. Block sizes are compressed
    + * into a single byte.
    + *
    + * @param loc location where the task is being executed.
    + * @param compressedSizes size of the blocks, indexed by reduce partition id.
    + */
    +private[spark] class DetailedMapStatus(
    +    private[this] var loc: BlockManagerId,
    +    private[this] var compressedSizes: Array[Byte])
    +  extends MapStatus with Externalizable {
    +
    +  protected def this() = this(null, null.asInstanceOf[Array[Byte]])  // For deserialization only
    +
    +  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    +    this(loc, uncompressedSizes.map(MapStatus.compressSize))
    +  }
     
    -  def writeExternal(out: ObjectOutput) {
    -    location.writeExternal(out)
    +  override def location: BlockManagerId = loc
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    MapStatus.decompressSize(compressedSizes(reduceId))
    +  }
    +
    +  override def writeExternal(out: ObjectOutput) {
    +    loc.writeExternal(out)
         out.writeInt(compressedSizes.length)
         out.write(compressedSizes)
       }
     
    -  def readExternal(in: ObjectInput) {
    -    location = BlockManagerId(in)
    -    compressedSizes = new Array[Byte](in.readInt())
    +  override def readExternal(in: ObjectInput) {
    --- End diff --
    
    These should return `: Unit`


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org


[GitHub] spark pull request: [SPARK-3613] Record only average block size in...

Posted by SparkQA <gi...@git.apache.org>.
Github user SparkQA commented on the pull request:

    https://github.com/apache/spark/pull/2470#issuecomment-57042065
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/20902/consoleFull) for   PR 2470 at commit [`f7e720a`](https://github.com/apache/spark/commit/f7e720aa93f348c20f8f9067ddba98550256e515).
     * This patch merges cleanly.


---
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 infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org