You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by JoshRosen <gi...@git.apache.org> on 2014/10/21 03:43:16 UTC

[GitHub] spark pull request: [SPARK-4019] Fix MapStatus compression bug tha...

GitHub user JoshRosen opened a pull request:

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

    [SPARK-4019] Fix MapStatus compression bug that could lead to empty results

    This commit fixes a bug in MapStatus that could cause jobs to wrongly return
    empty results if those jobs contained stages with more than 2000 partitions
    where most of those partitions were empty.
    
    For jobs with > 2000 partitions, MapStatus uses HighlyCompressedMapStatus,
    which only stores the average size of blocks.  If the average block size is
    zero, then this will cause all blocks to be reported as empty, causing
    BlockFetcherIterator to mistakenly skip them.
    
    For example, this would return an empty result:
    
        sc.makeRDD(0 until 10, 1000).repartition(2001).collect()
    
    The root problem here is that MapStatus has a (previously undocumented)
    correctness property that was violated by HighlyCompressedMapStatus:
    
        If a block is non-empty, then getSizeForBlock must be non-zero.
    
    I fixed this by introducing a new SparseCompressedMapStatus which only stores
    the sizes of non-empty blocks.  I also added new tests and assertions.

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

    $ git pull https://github.com/JoshRosen/spark spark-4019

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

    https://github.com/apache/spark/pull/2866.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 #2866
    
----
commit 91276a3bea64a11ff443baeb32df4ef1dab9d7c8
Author: Josh Rosen <jo...@databricks.com>
Date:   2014-10-21T01:34:57Z

    [SPARK-4019] Fix MapStatus compression bug that could lead to empty results.
    
    This commit fixes a bug in MapStatus that could cause jobs to wrongly return
    empty results if those jobs contained stages with more than 2000 partitions
    where most of those partitions were empty.
    
    For jobs with > 2000 partitions, MapStatus uses HighlyCompressedMapStatus,
    which only stores the average size of blocks.  If the average block size is
    zero, then this will cause all blocks to be reported as empty, causing
    BlockFetcherIterator to mistakenly skip them.
    
    For example, this would return an empty result:
    
        sc.makeRDD(0 until 10, 1000).repartition(2001).collect()
    
    The root problem here is that MapStatus has a (previously undocumented)
    correctness property that was violated by HighlyCompressedMapStatus:
    
        If a block is non-empty, then getSizeForBlock must be non-zero.
    
    I fixed this by introducing a new SparseCompressedMapStatus which only stores
    the sizes of non-empty blocks.  I also added new tests and assertions.

----


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59979144
  
    @JoshRosen Thank you. 


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60185926
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22057/consoleFull) for   PR 2866 at commit [`c8b8cae`](https://github.com/apache/spark/commit/c8b8cae37fcc153f808e5ef1405adec39a7d21cb).
     * 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59879396
  
    ;retest


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60321093
  
    LGTM!


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59876264
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/21957/consoleFull) for   PR 2866 at commit [`c23897a`](https://github.com/apache/spark/commit/c23897aea7881eb819ec074073a4431ec8ba7eb5).
     * This patch **fails PySpark 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19254919
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,70 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param nonEmptyBlocks a bitmap tracking which blocks are non-empty
    + * @param avgSize average size of the non-empty blocks
      */
     private[spark] class HighlyCompressedMapStatus(
         private[this] var loc: BlockManagerId,
    +    private[this] var nonEmptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || nonEmptyBlocks.getCardinality == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (nonEmptyBlocks.contains(reduceId)) {
    --- End diff --
    
    If you imagine mapOutputStatuses as a matrix where rows are map output and columns are reducers, the caller effectively slices per-reducer columns out of this matrix


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19187905
  
    --- Diff: core/src/test/scala/org/apache/spark/scheduler/MapStatusSuite.scala ---
    @@ -46,6 +47,27 @@ class MapStatusSuite extends FunSuite {
         }
       }
     
    +  test("MapStatus should never report non-empty blocks' sizes as 0") {
    +    import Math._
    +    for (
    +      numSizes <- Seq(1, 10, 100, 1000, 10000);
    +      mean <- Seq(0L, 100L, 10000L, Int.MaxValue.toLong);
    +      stddev <- Seq(0.0, 0.01, 0.5, 1.0)
    +    ) {
    +      val sizes =
    +        Array.tabulate[Long](numSizes)(_ => abs(round(Random.nextGaussian() * stddev)) + mean)
    --- End diff --
    
    u can do Array.fill to shorten this slightly


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19309149
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    +    var i = 0
    +    var numNonEmptyBlocks: Int = 0
    +    var totalSize: Long = 0
    +    // From a compression standpoint, it shouldn't matter whether we track empty or non-empty
    +    // blocks.  From a performance standpoint, we benefit from tracking empty blocks because
    --- End diff --
    
    :) I see. I've noticed this in your other PRs too.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59882089
  
    Actually instead of introducing a new one, what if we introduce a compressed bitmap that tracks zero-sized blocks, and then use avg size to track only non-zero blocks?


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60185796
  
    Thanks for the feedback.  I've updated this to track empty blocks instead of non-empty ones and used a HashSet to materialize the set of empty blocks so that lookups are constant time instead of logarithmic.


---
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-4019] Fix MapStatus compression bug tha...

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

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


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59989759
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22001/consoleFull) for   PR 2866 at commit [`609407d`](https://github.com/apache/spark/commit/609407de8a0bd78ca043de19c185c7a43bcf5b5e).
     * This patch **fails Scala style 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59883993
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/21964/consoleFull) for   PR 2866 at commit [`c23897a`](https://github.com/apache/spark/commit/c23897aea7881eb819ec074073a4431ec8ba7eb5).
     * This patch **passes all 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-4019] Fix MapStatus compression bug tha...

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

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


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59989609
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22001/consoleFull) for   PR 2866 at commit [`609407d`](https://github.com/apache/spark/commit/609407de8a0bd78ca043de19c185c7a43bcf5b5e).
     * 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59883237
  
    @rxin that's a fair solution, too, although the bitmap needs to be losslessly compressed.
    
    I could imagine cases where data is already partitioned but a user performs partition-preserving operations without specifying `preservesPartitioning`, then does a filtering operation that would otherwise benefit from partitioning.  In these cases, you might have this extreme bimodal distribution where most blocks are zero but the remaining blocks might be big.  In these cases, do you care about the exact sizes of those blocks?  Probably not in most cases, since there will be few blocks.
    
    I'll look into folding this into the compressed version as you've suggested.


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60012252
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22010/consoleFull) for   PR 2866 at commit [`ba2e71c`](https://github.com/apache/spark/commit/ba2e71c398c21a3b1f10d29d617c6d15e687ed6c).
     * This patch **passes all 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308831
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    --- End diff --
    
    Oh got it


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60189954
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22057/consoleFull) for   PR 2866 at commit [`c8b8cae`](https://github.com/apache/spark/commit/c8b8cae37fcc153f808e5ef1405adec39a7d21cb).
     * This patch **passes all tests**.
     * This patch merges cleanly.
     * This patch adds the following public classes _(experimental)_:
      * `class PRKryoRegistrator extends KryoRegistrator `
      * `  class ALSRegistrator extends KryoRegistrator `



---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60201281
  
    @JoshRosen thanks for doing this. There is a chance that a normal hashset is much slower than a bitmap. Can you test that? It might make a lot more sense to use an uncompressed bitmap to track after deserialization instead.


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19307851
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    +    var i = 0
    +    var numNonEmptyBlocks: Int = 0
    +    var totalSize: Long = 0
    +    // From a compression standpoint, it shouldn't matter whether we track empty or non-empty
    +    // blocks.  From a performance standpoint, we benefit from tracking empty blocks because
    --- End diff --
    
    Do you mean the space after the period ending the first sentence?


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59882025
  
    Oh wow. Thanks for fixing 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308335
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    --- End diff --
    
    when will this ever be null?


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19188129
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,70 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param nonEmptyBlocks a bitmap tracking which blocks are non-empty
    + * @param avgSize average size of the non-empty blocks
      */
     private[spark] class HighlyCompressedMapStatus(
    --- End diff --
    
    not that big of a deal, but maybe make the ctor private so it is always created via apply.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59990095
  
    I've updated this to use Roaring Bitmap for tracking which blocks are non-empty.  I also changed HighlyCompressedMapStatus to use the average size of only non-empty blocks; this should provide better estimates for map outputs that contain a few huge partitions and many empty ones.


---
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-4019] Fix MapStatus compression bug tha...

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

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


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60319091
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22091/consoleFull) for   PR 2866 at commit [`fc8b490`](https://github.com/apache/spark/commit/fc8b490e9c19f910c869118c46a16c6e4f8cb9d2).
     * 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59991650
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22004/consoleFull) for   PR 2866 at commit [`ba2e71c`](https://github.com/apache/spark/commit/ba2e71c398c21a3b1f10d29d617c6d15e687ed6c).
     * This patch **fails to build**.
     * 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19188111
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,70 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param nonEmptyBlocks a bitmap tracking which blocks are non-empty
    + * @param avgSize average size of the non-empty blocks
      */
     private[spark] class HighlyCompressedMapStatus(
         private[this] var loc: BlockManagerId,
    +    private[this] var nonEmptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || nonEmptyBlocks.getCardinality == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (nonEmptyBlocks.contains(reduceId)) {
    --- End diff --
    
    how efficient is RoaringBitmap for random access? 
    
    If I understand this correctly, I think the caller actually makes access to this sequentially (of reduceId). Is sequential call to contains efficient?
    
    cc @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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59991107
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22004/consoleFull) for   PR 2866 at commit [`ba2e71c`](https://github.com/apache/spark/commit/ba2e71c398c21a3b1f10d29d617c6d15e687ed6c).
     * 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308802
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    +    var i = 0
    +    var numNonEmptyBlocks: Int = 0
    +    var totalSize: Long = 0
    +    // From a compression standpoint, it shouldn't matter whether we track empty or non-empty
    +    // blocks.  From a performance standpoint, we benefit from tracking empty blocks because
    --- End diff --
    
    Yeah, was that intended?


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19299903
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
    --- End diff --
    
    can you update the comment to say that during serialization, we compress the bitmap, etc?


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

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


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308873
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    --- End diff --
    
    I feel like this is describing implementation details rather than how to use this method, so it feels inappropriate to put it in Javadoc.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59871966
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/21957/consoleFull) for   PR 2866 at commit [`c23897a`](https://github.com/apache/spark/commit/c23897aea7881eb819ec074073a4431ec8ba7eb5).
     * 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308465
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    --- End diff --
    
    During the default constructor that's called in readExternal.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59879420
  
    Jenkins, retest 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60004163
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22010/consoleFull) for   PR 2866 at commit [`ba2e71c`](https://github.com/apache/spark/commit/ba2e71c398c21a3b1f10d29d617c6d15e687ed6c).
     * 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-4019] [SPARK-3740] Fix MapStatus compre...

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

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


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59966852
  
    Compressed bitmaps are in general just variants of run-length encoding that is lossless. Which should be able to handle your case too.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59867805
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/21951/consoleFull) for   PR 2866 at commit [`91276a3`](https://github.com/apache/spark/commit/91276a3bea64a11ff443baeb32df4ef1dab9d7c8).
     * 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60003719
  
    Jenkins, retest 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308897
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    --- End diff --
    
    Isn't it also constant time there?


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59879704
  
      [QA tests have started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/21964/consoleFull) for   PR 2866 at commit [`c23897a`](https://github.com/apache/spark/commit/c23897aea7881eb819ec074073a4431ec8ba7eb5).
     * 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60325676
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/22091/consoleFull) for   PR 2866 at commit [`fc8b490`](https://github.com/apache/spark/commit/fc8b490e9c19f910c869118c46a16c6e4f8cb9d2).
     * This patch **passes all 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60318489
  
    Based on some discussion, we're going to stick with `RoaringBitmap.contains` for now.  Fancier solutions which use non-compressed bitmaps for lookups may be faster for certain lookup patterns, but this may cause other performance issues: each MapStatus is serialized / deserialized twice, once when it's created by the worker and sent to the master, and once when it's broadcast from the master to the worker, so the construction of these additional materializations could be expensive and it could be complicated to ensure that they're only created on the workers.


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308531
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    --- End diff --
    
    Why can't we just use `emptyBlocks.contains`? Why do we need to create a new set?


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308694
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    --- End diff --
    
    Maybe we should make this a java doc. This seems to describe what `apply` does pretty well.


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60307770
  
    Based on a [simple benchmark](https://gist.github.com/JoshRosen/5031568144f96475ed7b), it looks like Java BitSet performs slightly better for the types of access patterns that we use in Spark right now.  These access patterns can be changed to be more efficient, but this is a much more involved change that will need to be part of a larger refactoring of how we send map output statuses to reducers.
    
    Therefore, I'm going to replace my HashSet with a Java BitMap, wait for Jenkins, then commit this so we can fix this blocker.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59990957
  
    Jenkins, retest 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-4019] [SPARK-3740] Fix MapStatus compre...

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

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


---
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-4019] Fix MapStatus compression bug tha...

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

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


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60312382
  
    LGTM


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308629
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    --- End diff --
    
    I think the concern was that emptyBlocks.contains might be expensive.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#discussion_r19175249
  
    --- Diff: core/src/test/scala/org/apache/spark/scheduler/MapStatusSuite.scala ---
    @@ -56,37 +78,25 @@ class MapStatusSuite extends FunSuite {
         assert(status.getSizeForBlock(2000) === 150L)
       }
     
    -  test(classOf[HighlyCompressedMapStatus].getName + ": estimated size is within 10%") {
    --- End diff --
    
    I removed this test because it was broken as originally written.  The test says that it tests HighlyCompressedMapStatus's error, but it was broken because it never actually checked that the highly-compressed status was actually created.  Since this test only used 50 map outputs rather than > 2000, it never actually exercised HighlyCompressedMapStatus's code.


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19308925
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    +    var i = 0
    +    var numNonEmptyBlocks: Int = 0
    +    var totalSize: Long = 0
    +    // From a compression standpoint, it shouldn't matter whether we track empty or non-empty
    +    // blocks.  From a performance standpoint, we benefit from tracking empty blocks because
    --- End diff --
    
    I guess it's just a typing habit of mine. I keep forgetting that [the PC is not a typewriter](http://www.amazon.com/The-Not-Typewriter-Robin-Williams/dp/0938151495).


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59976845
  
    @Ishiihara Thanks for the reminder about Roaring BitMap.  I'm just going to do this myself, since it should only take a few minutes.


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19296417
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,70 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param nonEmptyBlocks a bitmap tracking which blocks are non-empty
    + * @param avgSize average size of the non-empty blocks
      */
     private[spark] class HighlyCompressedMapStatus(
         private[this] var loc: BlockManagerId,
    +    private[this] var nonEmptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || nonEmptyBlocks.getCardinality == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (nonEmptyBlocks.contains(reduceId)) {
    --- End diff --
    
    @rxin 
    
    Roaring is fast for random access. 
    
    I am not familiar with the code you point to, so I will not comment on its general effectiveness, but it does seem ok.
    
    If performance issues do arise, I would be glad to have a closer look.


---
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-4019] Fix MapStatus compression bug tha...

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

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


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19309194
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    --- End diff --
    
    I think @rxin looked into this and was concerned that this was logarithmic due to how it's implemented.  I haven't dug too deeply into the details though.


---
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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59871323
  
      [QA tests have finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/21951/consoleFull) for   PR 2866 at commit [`91276a3`](https://github.com/apache/spark/commit/91276a3bea64a11ff443baeb32df4ef1dab9d7c8).
     * This patch **fails Spark 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-4019] [SPARK-3740] Fix MapStatus compre...

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

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


---
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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#discussion_r19307726
  
    --- Diff: core/src/main/scala/org/apache/spark/scheduler/MapStatus.scala ---
    @@ -112,35 +119,82 @@ private[spark] class CompressedMapStatus(
       }
     }
     
    -
     /**
    - * A [[MapStatus]] implementation that only stores the average size of the blocks.
    + * A [[MapStatus]] implementation that only stores the average size of non-empty blocks,
    + * plus a bitmap for tracking which blocks are non-empty.
      *
    - * @param loc location where the task is being executed.
    - * @param avgSize average size of all the blocks
    + * @param loc location where the task is being executed
    + * @param numNonEmptyBlocks the number of non-empty blocks
    + * @param emptyBlocks a bitmap tracking which blocks are empty
    + * @param avgSize average size of the non-empty blocks
      */
    -private[spark] class HighlyCompressedMapStatus(
    +private[spark] class HighlyCompressedMapStatus private (
         private[this] var loc: BlockManagerId,
    +    private[this] var numNonEmptyBlocks: Int,
    +    private[this] var emptyBlocks: RoaringBitmap,
         private[this] var avgSize: Long)
       extends MapStatus with Externalizable {
     
    -  def this(loc: BlockManagerId, uncompressedSizes: Array[Long]) {
    -    this(loc, uncompressedSizes.sum / uncompressedSizes.length)
    -  }
    +  require(loc == null || avgSize > 0 || numNonEmptyBlocks == 0,
    +    "Average size can only be zero for map stages that produced no output")
     
    -  protected def this() = this(null, 0L)  // For deserialization only
    +  protected def this() = this(null, -1, null, -1)  // For deserialization only
     
       override def location: BlockManagerId = loc
     
    -  override def getSizeForBlock(reduceId: Int): Long = avgSize
    +  // This set allows for constant-time lookup of whether a block is empty
    +  private var emptyBlocksSet: Set[Int] = Option(emptyBlocks).map(_.toArray.toSet).orNull
    +
    +  override def getSizeForBlock(reduceId: Int): Long = {
    +    if (emptyBlocksSet.contains(reduceId)) {
    +      0
    +    } else {
    +      avgSize
    +    }
    +  }
     
       override def writeExternal(out: ObjectOutput): Unit = {
         loc.writeExternal(out)
    +    emptyBlocks.writeExternal(out)
         out.writeLong(avgSize)
       }
     
       override def readExternal(in: ObjectInput): Unit = {
         loc = BlockManagerId(in)
    +    emptyBlocks = new RoaringBitmap()
    +    emptyBlocks.readExternal(in)
    +    emptyBlocksSet = emptyBlocks.toArray.toSet
         avgSize = in.readLong()
       }
     }
    +
    +object HighlyCompressedMapStatus {
    +  def apply(loc: BlockManagerId, uncompressedSizes: Array[Long]): HighlyCompressedMapStatus = {
    +    // We must keep track of which blocks are empty so that we don't report a zero-sized
    +    // block as being non-empty (or vice-versa) when using the average block size.
    +    var i = 0
    +    var numNonEmptyBlocks: Int = 0
    +    var totalSize: Long = 0
    +    // From a compression standpoint, it shouldn't matter whether we track empty or non-empty
    +    // blocks.  From a performance standpoint, we benefit from tracking empty blocks because
    --- End diff --
    
    1 too many spaces 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-4019] Fix MapStatus compression bug tha...

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

    https://github.com/apache/spark/pull/2866#issuecomment-59883834
  
    @JoshRosen I have been looking into the compressed bitmap and already get a good idea of how to use roaring bitmap to perform the task. If this work is not urgent, can you give me one day or two to get the compressed bitmap part completed? 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-4019] [SPARK-3740] Fix MapStatus compre...

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

    https://github.com/apache/spark/pull/2866#issuecomment-60325904
  
    Okay I'm gonna pull this in - thanks Josh!


---
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-4019] Fix MapStatus compression bug tha...

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

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


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