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

[GitHub] spark pull request: Spark 5659 Flaky test: o.a.s.streaming.Receive...

GitHub user kevinpetersavage opened a pull request:

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

    Spark 5659 Flaky test: o.a.s.streaming.ReceiverSuite.block

    I made two changes to fix this. First I replaced the RateLimiter code with guavas rate limiter which seemed to behave better. I added an extra couple of tests for this class. 
    
    Secondly I simplified the assertions in the test so that we send a fixed number of messages and assert on the wait time (rather than the other way round). I also completely removed the last assertion which check for roughly equal batch sizes because I think it is not valid. The JVM might just be doing other things, stopping this being predictable and indeed in my testing I found that while we expected ~10 messages per block we sometimes got things like 50 messages in one block.

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

    $ git pull https://github.com/kevinpetersavage/spark SPARK-5659

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

    https://github.com/apache/spark/pull/4957.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 #4957
    
----
commit c39211bd6858b82df5f8e2551a7bbaaeb78d88f7
Author: Kevin Savage <ke...@jos-air-2.home>
Date:   2015-03-08T00:58:39Z

    SPARK-5659: Fix flaky test o.a.s.streaming.ReceiverSuite.block. Simplifies RateLimiter and removes assertion that is not valid.

commit b11b4e13d085b6103f27bfac25eba62244023807
Author: Kevin Savage <ke...@jos-macbook-air-2.local>
Date:   2015-03-09T22:01:10Z

    Merge branch 'master' into SPARK-5659

----


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

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


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26092901
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
         val maxRate = 100
         val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
           set("spark.streaming.receiver.maxRate", maxRate.toString)
    -    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         val expectedBlocks = 20
         val waitTime = expectedBlocks * blockInterval
         val expectedMessages = maxRate * waitTime / 1000
    -    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    -    val generatedData = new ArrayBuffer[Int]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than the theoretical minimum time")
    +
    +    // we should get the same data
         val recordedBlocks = blockGeneratorListener.arrayBuffers
         val recordedData = recordedBlocks.flatten
         assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks received")
         assert(recordedData.toSet === generatedData.toSet, "Received data not same")
    --- End diff --
    
    This is a superset assertion of the previous line, so this one should suffice.


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-85535312
  
    I think this fixes the original flaky test problem. It does it by fixing a previously unknown problem with the sizes of batches, but probably not in the way expected. I am happy with this pending review. 
    
    What do you think @tdas?  


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-77965080
  
    Can one of the admins verify this patch?


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26146158
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
         val maxRate = 100
         val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
           set("spark.streaming.receiver.maxRate", maxRate.toString)
    -    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         val expectedBlocks = 20
         val waitTime = expectedBlocks * blockInterval
         val expectedMessages = maxRate * waitTime / 1000
    -    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    -    val generatedData = new ArrayBuffer[Int]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than the theoretical minimum time")
    +
    +    // we should get the same data
         val recordedBlocks = blockGeneratorListener.arrayBuffers
         val recordedData = recordedBlocks.flatten
         assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks received")
         assert(recordedData.toSet === generatedData.toSet, "Received data not same")
    -
    --- End diff --
    
    Interesting! It could be that because of GC or something one 200 ms
    interval received only 1 record (far below rate limit), which allowed the
    next 200 ms interval to received 49 (above rate in terms of 200 ms but
    still below rate in terms of the 400 ms interval). It could be that the
    rate limiter we had did not synchronize time and count in sync with the
    block intervals. Whatever the solutions is, it should do make all the
    blocks as even as possible. Uneven blocks would become a bottleneck in
    processing the corresponding batch.
    
    Thanks for looking into this :)
    
    
    On Tue, Mar 10, 2015 at 4:14 AM, Kevin <no...@github.com> wrote:
    
    > In streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala
    > <https://github.com/apache/spark/pull/4957#discussion_r26113197>:
    >
    > >      val recordedBlocks = blockGeneratorListener.arrayBuffers
    > >      val recordedData = recordedBlocks.flatten
    > >      assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks received")
    > >      assert(recordedData.toSet === generatedData.toSet, "Received data not same")
    > > -
    >
    > The thing is, it doesn't actually seem to do that. The test is expecting
    > to get ~10 messages per block. I ran the test a few times and saw numbers
    > like 49 and 1. I also got corresponding varying numbers of messages.
    >
    > I'll have another look and see if I can find a more reliable way of doing
    > this.
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/spark/pull/4957/files#r26113197>.
    >



---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-93114895
  
    The problem with this approach is that that data is getting copied over through multiple data structures, first the queue and then the new block. That is definitely going to hurt performance. That why once things are in the ArrayBuffer the buffer as a whole in inserted, without further copying (at least not on the receiver side). 
    
    Rather the existing approach with your fix of using the Guava rate limiter is desirable. Might be better to play around with that approach.


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26092995
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/receiver/RateLimiterSuite.scala ---
    @@ -0,0 +1,48 @@
    +/*
    + * Licensed to the Apache Software Foundation (ASF) under one or more
    + * contributor license agreements.  See the NOTICE file distributed with
    + * this work for additional information regarding copyright ownership.
    + * The ASF licenses this file to You under the Apache License, Version 2.0
    + * (the "License"); you may not use this file except in compliance with
    + * the License.  You may obtain a copy of the License at
    + *
    + *    http://www.apache.org/licenses/LICENSE-2.0
    + *
    + * Unless required by applicable law or agreed to in writing, software
    + * distributed under the License is distributed on an "AS IS" BASIS,
    + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
    + * See the License for the specific language governing permissions and
    + * limitations under the License.
    + */
    +
    +package org.apache.spark.streaming.receiver
    +
    +import java.util.concurrent.TimeUnit
    +
    +import com.google.common.base.Stopwatch
    --- End diff --
    
    Please add a line between the import sections defined in 
    https://cwiki.apache.org/confluence/display/SPARK/Spark+Code+Style+Guide


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-78524617
  
    Wrong button, didn't mean to close :-)


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-78524314
  
    I had a bit more of a think about this based on the comments so far. I think that what we really care about is blocks that are too large because we might perform super linear algorithms on them. With this in mind I've implemented an independent limit to block size called "spark.streaming.maxBlockSize". 
    
    If maxBlockSize is set, you can't get blocks that are bigger than the number you set it to. It defaults to Long.MaxValue so that we keep the current behaviour if it isn't set. I've adjusted the tests so that they only check the upper bound on the message sizes and the lower bound on the number of messages as these are now the only guarantees.
    
    I think this seems like reasonable behaviour for the goals and the test passes every time for me now. Do you think this is sufficient?


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26113197
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
         val maxRate = 100
         val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
           set("spark.streaming.receiver.maxRate", maxRate.toString)
    -    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         val expectedBlocks = 20
         val waitTime = expectedBlocks * blockInterval
         val expectedMessages = maxRate * waitTime / 1000
    -    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    -    val generatedData = new ArrayBuffer[Int]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than the theoretical minimum time")
    +
    +    // we should get the same data
         val recordedBlocks = blockGeneratorListener.arrayBuffers
         val recordedData = recordedBlocks.flatten
         assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks received")
         assert(recordedData.toSet === generatedData.toSet, "Received data not same")
    -
    --- End diff --
    
    The thing is, it doesn't actually seem to do that. The test is expecting to get ~10 messages per block. I ran the test a few times and saw numbers like 49 and 1. I also got corresponding varying numbers of messages.
    
    I'll have another look and see if I can find a more reliable way of doing 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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-95219959
  
    Sorry @tdas, crossed wires, didn't see your comment before I'd already looked at this. 
    
    I see your point, but I think that the underlying problem with the test was that batches were not limited above. Without fixing this I don't really see how you can fix the test. I also don't think you can fix it by doing timing better because we're on the JVM. I think that the change I just made is a reasonable hybrid that doesn't do copying though data structures. 
    
    Would it be a better idea to create a bug about block sizes that can be too large and submit this as a fix for that bug so that it can be reviewed properly?


---
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 5659 Flaky test: o.a.s.streaming.Receive...

Posted by kevinpetersavage <gi...@git.apache.org>.
GitHub user kevinpetersavage reopened a pull request:

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

    Spark 5659 Flaky test: o.a.s.streaming.ReceiverSuite.block

    I made two changes to fix this. First I replaced the RateLimiter code with guavas rate limiter which seemed to behave better. I added an extra couple of tests for this class. 
    
    Secondly I simplified the assertions in the test so that we send a fixed number of messages and assert on the wait time (rather than the other way round). I also completely removed the last assertion which check for roughly equal batch sizes because I think it is not valid. The JVM might just be doing other things, stopping this being predictable and indeed in my testing I found that while we expected ~10 messages per block we sometimes got things like 50 messages in one block.

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

    $ git pull https://github.com/kevinpetersavage/spark SPARK-5659

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

    https://github.com/apache/spark/pull/4957.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 #4957
    
----
commit c39211bd6858b82df5f8e2551a7bbaaeb78d88f7
Author: Kevin Savage <ke...@jos-air-2.home>
Date:   2015-03-08T00:58:39Z

    SPARK-5659: Fix flaky test o.a.s.streaming.ReceiverSuite.block. Simplifies RateLimiter and removes assertion that is not valid.

commit b11b4e13d085b6103f27bfac25eba62244023807
Author: Kevin Savage <ke...@jos-macbook-air-2.local>
Date:   2015-03-09T22:01:10Z

    Merge branch 'master' into SPARK-5659

commit 10c502c241988df5db0e42dffd7510fb53f4422f
Author: Kevin Savage <ke...@mendeley.com>
Date:   2015-03-12T12:19:32Z

    SPARK-5659: limit the number of messages in a block

commit ac8a07ac6e6b6f87ce43f8713a36bc14c005aa5d
Author: Kevin Savage <ke...@mendeley.com>
Date:   2015-03-12T12:27:16Z

    SPARK-5659: implement suggested changes

commit 158cd89d450112d16885ca4f11dc98da365fa339
Author: Kevin Savage <ke...@mendeley.com>
Date:   2015-03-12T15:51:04Z

    SPARK-5659: fix line being to long

----


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-96902804
  
    This is ok to test.
    
    On Mon, Apr 27, 2015 at 11:21 AM, UCB AMPLab <no...@github.com>
    wrote:
    
    > Can one of the admins verify this patch?
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/spark/pull/4957#issuecomment-96769225>.
    >



---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26092776
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
         val maxRate = 100
         val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
           set("spark.streaming.receiver.maxRate", maxRate.toString)
    -    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         val expectedBlocks = 20
         val waitTime = expectedBlocks * blockInterval
         val expectedMessages = maxRate * waitTime / 1000
    -    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    -    val generatedData = new ArrayBuffer[Int]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than the theoretical minimum time")
    --- End diff --
    
    I like 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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-85316759
  
    @tdas @kevinpetersavage what is the status of this fix?


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26092828
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
         val maxRate = 100
         val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
           set("spark.streaming.receiver.maxRate", maxRate.toString)
    -    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         val expectedBlocks = 20
         val waitTime = expectedBlocks * blockInterval
         val expectedMessages = maxRate * waitTime / 1000
    -    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    -    val generatedData = new ArrayBuffer[Int]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than the theoretical minimum time")
    +
    +    // we should get the same data
         val recordedBlocks = blockGeneratorListener.arrayBuffers
         val recordedData = recordedBlocks.flatten
         assert(blockGeneratorListener.arrayBuffers.size > 0, "No blocks received")
         assert(recordedData.toSet === generatedData.toSet, "Received data not same")
    -
    --- End diff --
    
    I had added these test to make sure each block generated gets around expected number of messages. Ultimately that is the goal of the rate limiter in the block generator, the block to not contains more than the expected number of messages. 


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-96677479
  
    @huitseeker Yes, sure. Let me know how/when. 


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#discussion_r26113001
  
    --- Diff: streaming/src/test/scala/org/apache/spark/streaming/ReceiverSuite.scala ---
    @@ -161,50 +161,27 @@ class ReceiverSuite extends TestSuiteBase with Timeouts with Serializable {
         val maxRate = 100
         val conf = new SparkConf().set("spark.streaming.blockInterval", blockInterval.toString).
           set("spark.streaming.receiver.maxRate", maxRate.toString)
    -    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         val expectedBlocks = 20
         val waitTime = expectedBlocks * blockInterval
         val expectedMessages = maxRate * waitTime / 1000
    -    val expectedMessagesPerBlock = maxRate * blockInterval / 1000
    -    val generatedData = new ArrayBuffer[Int]
    +    val generatedData = 0 until expectedMessages
     
         // Generate blocks
         val startTime = System.currentTimeMillis()
    +    val blockGenerator = new BlockGenerator(blockGeneratorListener, 1, conf)
         blockGenerator.start()
    -    var count = 0
    -    while(System.currentTimeMillis - startTime < waitTime) {
    -      blockGenerator.addData(count)
    -      generatedData += count
    -      count += 1
    -      Thread.sleep(1)
    -    }
    +    generatedData.foreach(blockGenerator.addData(_))
         blockGenerator.stop()
    +    val endTime = System.currentTimeMillis()
     
    +    // should have been rate limited
    +    assert(endTime - startTime >= waitTime, "Should have taken longer than the theoretical minimum time")
    --- End diff --
    
    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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-77970730
  
    ok to test
    



---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-96769225
  
    Can one of the admins verify this patch?


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-94969012
  
    @kevinpetersavage Any thoughts on 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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-95175963
  
    I suggest not making invasive changes as part of this JIRA. This is flaky
    test fix jira, and changing the performance-critical flow of data is a bad
    idea.
    
    
    On Wed, Apr 22, 2015 at 3:51 AM, Kevin <no...@github.com> wrote:
    
    > I think we will still have a problem with upper bounding the blocks if we
    > just use timers, that was the original issue. I agree with the point on
    > performance though. I'll have another look and see if I can combine the two
    > approaches to get rid of the copy somehow.
    >
    > —
    > Reply to this email directly or view it on GitHub
    > <https://github.com/apache/spark/pull/4957#issuecomment-95133444>.
    >



---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-89788272
  
    Any further comments @tdas?


---
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 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-96651065
  
    @kevinpetersavage @tdas I really like some of the ideas in that PR. We (Typesafe) are getting to something very close with our Spark Streaming work, except with block sizes that are dynamic.
    
    @kevinpetersavage Mind doing some early review work on an upcoming design document that addresses the same problem ?


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

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


[GitHub] spark pull request: Spark 5659 Flaky test: o.a.s.streaming.Receive...

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

    https://github.com/apache/spark/pull/4957#issuecomment-95133444
  
    I think we will still have a problem with upper bounding the blocks if we just use timers, that was the original issue. I agree with the point on performance though. I'll have another look and see if I can combine the two approaches to get rid of the copy somehow. 


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