You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by GitBox <gi...@apache.org> on 2020/05/10 00:14:33 UTC
[GitHub] [spark] oleg-smith opened a new pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
oleg-smith opened a new pull request #28488:
URL: https://github.com/apache/spark/pull/28488
<!--
Thanks for sending a pull request! Here are some tips for you:
1. If this is your first time, please read our contributor guidelines: https://spark.apache.org/contributing.html
2. Ensure you have added or run the appropriate tests for your PR: https://spark.apache.org/developer-tools.html
3. If the PR is unfinished, add '[WIP]' in your PR title, e.g., '[WIP][SPARK-XXXX] Your PR title ...'.
4. Be sure to keep the PR description updated to reflect all changes.
5. Please write your PR title to summarize what this PR proposes.
6. If possible, provide a concise example to reproduce the issue for a faster review.
7. If you want to add a new configuration, please read the guideline first for naming configurations in
'core/src/main/scala/org/apache/spark/internal/config/ConfigEntry.scala'.
-->
### What changes were proposed in this pull request?
<!--
Please clarify what changes you are proposing. The purpose of this section is to outline the changes and how this PR fixes the issue.
If possible, please consider writing useful notes for better and faster reviews in your PR. See the examples below.
1. If you refactor some codes with changing classes, showing the class hierarchy will help reviewers.
2. If you fix some SQL features, you can provide some references of other DBMSes.
3. If there is design documentation, please add the link.
4. If there is a discussion in the mailing list, please add the link.
-->
### Why are the changes needed?
<!--
Please clarify why the changes are needed. For instance,
1. If you propose a new API, clarify the use case for a new API.
2. If you fix a bug, you can clarify why it is a bug.
-->
### Does this PR introduce _any_ user-facing change?
<!--
Note that it means *any* user-facing change including all aspects such as the documentation fix.
If yes, please clarify the previous behavior and the change this PR proposes - provide the console output, description and/or an example to show the behavior difference if possible.
If possible, please also clarify if this is a user-facing change compared to the released Spark versions or within the unreleased branches such as master.
If no, write 'No'.
-->
### How was this patch tested?
<!--
If tests were added, say they were added here. Please make sure to add some test cases that check the changes thoroughly including negative and positive cases if possible.
If it was tested in a way different from regular unit tests, please clarify how you tested step by step, ideally copy and paste-able, so that other reviewers can test and check, and descendants can verify in the future.
If tests were not added, please describe why they were not added and/or why it was difficult to add.
-->
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630451357
@holdenk @srowen ok to merge?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626385672
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/122480/
Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] holdenk commented on a change in pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
holdenk commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422572289
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1032,101 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+
+ if (!prefetchPartitions || partitions.indices.isEmpty) {
+ def collectPartition(p: Int): Array[T] = {
+ sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ }
+ partitions.indices.iterator.flatMap(i => collectPartition(i))
+
+ } else {
+
+ val iterator: Iterator[Array[T]] = prefetchingIterator
+ iterator.hasNext
+ iterator.flatMap(data => data)
+ }
+ }
+
+ private def prefetchingIterator: Iterator[Array[T]] = {
+
+ val partitionIterator = partitions.indices.iterator
+
+ new Iterator[Array[T]] with Serializable {
+
+ private val lock = new ReentrantLock()
+ private val ready = lock.newCondition()
+
+ private var nextResult: Array[T] = _
+ private var fetchInProgress = false
+
+ /**
+ * In addition, it prefetches next element, if it exists
+ */
+ override def hasNext(): Boolean = withLock(() => {
+ if (fetchInProgress) true
Review comment:
What about if the next partition is empty?
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1032,101 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+
+ if (!prefetchPartitions || partitions.indices.isEmpty) {
+ def collectPartition(p: Int): Array[T] = {
+ sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ }
+ partitions.indices.iterator.flatMap(i => collectPartition(i))
+
Review comment:
Minor style: we don't normally leave an empty line here
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626323488
**[Test build #122475 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122475/testReport)** for PR 28488 at commit [`9ece2f5`](https://github.com/apache/spark/commit/9ece2f542c31614f825516c838f2ed0740258892).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626284155
**[Test build #122470 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122470/testReport)** for PR 28488 at commit [`72fc400`](https://github.com/apache/spark/commit/72fc400d40fbdc73a3e8285e06d7ae6b9e547cae).
* This patch **fails due to an unknown error code, -9**.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626362222
**[Test build #122478 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122478/testReport)** for PR 28488 at commit [`f43bd97`](https://github.com/apache/spark/commit/f43bd97d9c082825533033c4df0fd7f75575f210).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628317955
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/122600/
Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630564778
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/122822/
Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628317935
**[Test build #122600 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122600/testReport)** for PR 28488 at commit [`6c3856d`](https://github.com/apache/spark/commit/6c3856d5d82de3f98cd0dd93e951b8355e93fe7f).
* This patch **fails build dependency tests**.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422711668
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1033,24 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
- }
- partitions.indices.iterator.flatMap(i => collectPartition(i))
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+ val iterator = new PrefetchingIterator(this, prefetchPartitions)
+ if (prefetchPartitions) iterator.hasNext
Review comment:
Agreed, I'd push evaluation until later, until hasNext or next is called.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626258151
@BryanCutler @HyukjinKwon @holdenk Could you review please?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626253290
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626272714
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626362370
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith edited a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith edited a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628308986
@BryanCutler I reverted PythonRDD change and answered the rest. Let me know if you have more questions
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626379049
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/122478/
Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626386745
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626368132
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628317950
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626385670
Merged build finished. Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626344612
**[Test build #122475 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122475/testReport)** for PR 28488 at commit [`9ece2f5`](https://github.com/apache/spark/commit/9ece2f542c31614f825516c838f2ed0740258892).
* This patch passes all tests.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630564401
**[Test build #122822 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122822/testReport)** for PR 28488 at commit [`6c3856d`](https://github.com/apache/spark/commit/6c3856d5d82de3f98cd0dd93e951b8355e93fe7f).
* This patch **fails PySpark unit tests**.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r424796523
##########
File path: core/src/main/scala/org/apache/spark/rdd/util/PrefetchingIterator.scala
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.rdd.util
+
+import java.util.concurrent.atomic.AtomicReference
+import java.util.concurrent.locks.ReentrantLock
+
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.reflect.ClassTag
+import scala.util.Try
+
+import org.apache.spark.rdd.RDD
+
+/**
+ * Iterator that optionally prefetches next partition asynchronously
+ */
+private[spark] class PrefetchingIterator[T : ClassTag](
+ rdd: RDD[T],
+ prefetch: Boolean)
+ extends Iterator[Array[T]]
+ with Serializable {
+
+ private val partitionIterator = rdd.partitions.indices.iterator
+
+ private val lock = new ReentrantLock()
Review comment:
since job is executed in other thread, the need is it to thread-safely pass the job result back to iterator
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
srowen commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422678936
##########
File path: core/src/test/java/test/org/apache/spark/JavaAPISuite.java
##########
@@ -81,6 +51,26 @@
import org.apache.spark.storage.StorageLevel;
import org.apache.spark.util.LongAccumulator;
import org.apache.spark.util.StatCounter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import scala.Tuple2;
+import scala.Tuple3;
+import scala.Tuple4;
+import scala.collection.JavaConverters;
+
+import java.io.*;
Review comment:
Revert the import changes please
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626386553
**[Test build #122482 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122482/testReport)** for PR 28488 at commit [`d0957cb`](https://github.com/apache/spark/commit/d0957cb1e207d806b9ea6333b0deb4866dcecbbb).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626370493
@srowen The implemented approach gets 1 partition ahead, not N.
I'd appreciate it if you were more specific instead of pointing to JIRA discussion that I have read.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422698223
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1033,24 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
- }
- partitions.indices.iterator.flatMap(i => collectPartition(i))
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+ val iterator = new PrefetchingIterator(this, prefetchPartitions)
+ if (prefetchPartitions) iterator.hasNext
Review comment:
@holdenk @srowen Should we not prefetch the very first element here?
For a user, it might be better to get iterator without side effects first, and submit jobs or receive errors only if iteration was intentionally started.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626344906
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-635021200
@holdenk @srowen @jiangxb1987 ok to merge?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-683375681
@holdenk could you merge if everything is fine to you?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626284267
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/122470/
Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626272714
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628308986
@BryanCutler I reverted PythonRDD change and replied. Let me know if you have more questions
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] BryanCutler commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
BryanCutler commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r424741536
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -18,6 +18,7 @@
package org.apache.spark.rdd
import java.util.Random
+import java.util.concurrent.locks.ReentrantLock
Review comment:
Unused?
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1033,22 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
- }
- partitions.indices.iterator.flatMap(i => collectPartition(i))
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+ new PrefetchingIterator(this, prefetchPartitions).flatMap(data => data)
Review comment:
why `flatMap` here? doesn't look like anything is being mapped
##########
File path: core/src/main/scala/org/apache/spark/rdd/util/PrefetchingIterator.scala
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.rdd.util
+
+import java.util.concurrent.atomic.AtomicReference
+import java.util.concurrent.locks.ReentrantLock
+
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.reflect.ClassTag
+import scala.util.Try
+
+import org.apache.spark.rdd.RDD
+
+/**
+ * Iterator that optionally prefetches next partition asynchronously
+ */
+private[spark] class PrefetchingIterator[T : ClassTag](
+ rdd: RDD[T],
+ prefetch: Boolean)
+ extends Iterator[Array[T]]
+ with Serializable {
+
+ private val partitionIterator = rdd.partitions.indices.iterator
+
+ private val lock = new ReentrantLock()
Review comment:
Could you explain the need for a lock here?
##########
File path: core/src/main/scala/org/apache/spark/api/java/JavaRDDLike.scala
##########
@@ -368,6 +368,9 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
def toLocalIterator(): JIterator[T] =
asJavaIteratorConverter(rdd.toLocalIterator).asJava
+ def toLocalIterator(prefetchPartitions: Boolean): JIterator[T] =
Review comment:
nit: `prefetchPartitions` sounds like it will prefetch multiple partitions, but it is only the next one correct? Maybe rename this and elsewhere to `prefetchNextPartition`?
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1033,22 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
- }
- partitions.indices.iterator.flatMap(i => collectPartition(i))
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
Review comment:
Should there be a default value since there is already `def toLocalIterator` above?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626253365
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626323488
**[Test build #122475 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122475/testReport)** for PR 28488 at commit [`9ece2f5`](https://github.com/apache/spark/commit/9ece2f542c31614f825516c838f2ed0740258892).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626404987
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626344906
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626385670
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626272623
**[Test build #122470 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122470/testReport)** for PR 28488 at commit [`72fc400`](https://github.com/apache/spark/commit/72fc400d40fbdc73a3e8285e06d7ae6b9e547cae).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626368146
@oleg-smith have a look at the JIRA discussion. I think the proposal was to fetch many partitions in parallel, which is at odds with the idea of toLocalIterator (1 element at a time, maybe 1 partition at a time as implemented, but not N).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626368132
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630499182
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630564771
Merged build finished. Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628310240
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626404987
Merged build finished. Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626386745
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626323649
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626386553
**[Test build #122482 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122482/testReport)** for PR 28488 at commit [`d0957cb`](https://github.com/apache/spark/commit/d0957cb1e207d806b9ea6333b0deb4866dcecbbb).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626367982
**[Test build #122480 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122480/testReport)** for PR 28488 at commit [`d4a838c`](https://github.com/apache/spark/commit/d4a838cf2801ae4d941507d81b213cf87d161f93).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630501057
**[Test build #122822 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122822/testReport)** for PR 28488 at commit [`6c3856d`](https://github.com/apache/spark/commit/6c3856d5d82de3f98cd0dd93e951b8355e93fe7f).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626362370
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626253290
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626323649
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r424796523
##########
File path: core/src/main/scala/org/apache/spark/rdd/util/PrefetchingIterator.scala
##########
@@ -0,0 +1,103 @@
+/*
+ * 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.rdd.util
+
+import java.util.concurrent.atomic.AtomicReference
+import java.util.concurrent.locks.ReentrantLock
+
+import scala.concurrent.ExecutionContext.Implicits.global
+import scala.reflect.ClassTag
+import scala.util.Try
+
+import org.apache.spark.rdd.RDD
+
+/**
+ * Iterator that optionally prefetches next partition asynchronously
+ */
+private[spark] class PrefetchingIterator[T : ClassTag](
+ rdd: RDD[T],
+ prefetch: Boolean)
+ extends Iterator[Array[T]]
+ with Serializable {
+
+ private val partitionIterator = rdd.partitions.indices.iterator
+
+ private val lock = new ReentrantLock()
Review comment:
since job is executed in other thread, the need of it is to thread-safely pass the job result back to iterator
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628310240
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] jiangxb1987 commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
jiangxb1987 commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630498742
retest this please
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626404988
Test FAILed.
Refer to this link for build results (access rights to CI server needed):
https://amplab.cs.berkeley.edu/jenkins//job/SparkPullRequestBuilder/122482/
Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626366492
I recall this was discussed at https://issues.apache.org/jira/browse/SPARK-27025?focusedCommentId=16782789&page=com.atlassian.jira.plugin.system.issuetabpanels%3Acomment-tabpanel#comment-16782789 which might be worth a read. I think the TL;DR from me was that fetching 1 additional iterator could be fine.
I'm a little worried about correctness issues, thread-safety, in the presence of failures, etc. Like where do you get the error when if the prefetch fails? but I have not thought it through.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626284263
Merged build finished. Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] srowen commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
srowen commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626373572
I know. I'm saying that's probably still fine as an approach.
I am still concerned about error case. What happens when the prefetch fails - when does the user see the error?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r424795937
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1033,22 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
- }
- partitions.indices.iterator.flatMap(i => collectPartition(i))
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
Review comment:
the problem is the existing method is without ().
if i reused it and added default value, it'd bring source incompatibility
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626284263
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422680143
##########
File path: core/src/test/java/test/org/apache/spark/JavaAPISuite.java
##########
@@ -81,6 +51,26 @@
import org.apache.spark.storage.StorageLevel;
import org.apache.spark.util.LongAccumulator;
import org.apache.spark.util.StatCounter;
+import org.junit.After;
+import org.junit.Before;
+import org.junit.Test;
+import scala.Tuple2;
+import scala.Tuple3;
+import scala.Tuple4;
+import scala.collection.JavaConverters;
+
+import java.io.*;
Review comment:
fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626385538
**[Test build #122480 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122480/testReport)** for PR 28488 at commit [`d4a838c`](https://github.com/apache/spark/commit/d4a838cf2801ae4d941507d81b213cf87d161f93).
* This patch **fails PySpark unit tests**.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626378873
**[Test build #122478 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122478/testReport)** for PR 28488 at commit [`f43bd97`](https://github.com/apache/spark/commit/f43bd97d9c082825533033c4df0fd7f75575f210).
* This patch **fails PySpark unit tests**.
* This patch merges cleanly.
* This patch adds the following public classes _(experimental)_:
* `class PrefetchingIterator[T : ClassTag](rdd: RDD[T],`
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626367318
@srowen could you clarify what it means:
> fetching 1 additional iterator could be fine.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626379048
Merged build finished. Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630499182
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626404817
**[Test build #122482 has finished](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122482/testReport)** for PR 28488 at commit [`d0957cb`](https://github.com/apache/spark/commit/d0957cb1e207d806b9ea6333b0deb4866dcecbbb).
* This patch **fails PySpark unit tests**.
* This patch merges cleanly.
* This patch adds no public classes.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] HyukjinKwon commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
HyukjinKwon commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626272338
ok to test
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628309946
**[Test build #122600 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122600/testReport)** for PR 28488 at commit [`6c3856d`](https://github.com/apache/spark/commit/6c3856d5d82de3f98cd0dd93e951b8355e93fe7f).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626386539
@srowen agree, added exception propagation to the caller thread
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628309946
**[Test build #122600 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122600/testReport)** for PR 28488 at commit [`6c3856d`](https://github.com/apache/spark/commit/6c3856d5d82de3f98cd0dd93e951b8355e93fe7f).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-640149979
@holdenk could you merge if everything is fine to you?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626272623
**[Test build #122470 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122470/testReport)** for PR 28488 at commit [`72fc400`](https://github.com/apache/spark/commit/72fc400d40fbdc73a3e8285e06d7ae6b9e547cae).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630501057
**[Test build #122822 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122822/testReport)** for PR 28488 at commit [`6c3856d`](https://github.com/apache/spark/commit/6c3856d5d82de3f98cd0dd93e951b8355e93fe7f).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
github-actions[bot] commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-741340365
We're closing this PR because it hasn't been updated in a while. This isn't a judgement on the merit of the PR in any way. It's just a way of keeping the PR queue manageable.
If you'd like to revive this PR, please reopen it and ask a committer to remove the Stale tag!
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626367982
**[Test build #122480 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122480/testReport)** for PR 28488 at commit [`d4a838c`](https://github.com/apache/spark/commit/d4a838cf2801ae4d941507d81b213cf87d161f93).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626253365
Can one of the admins verify this patch?
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r424795564
##########
File path: core/src/main/scala/org/apache/spark/api/java/JavaRDDLike.scala
##########
@@ -368,6 +368,9 @@ trait JavaRDDLike[T, This <: JavaRDDLike[T, This]] extends Serializable {
def toLocalIterator(): JIterator[T] =
asJavaIteratorConverter(rdd.toLocalIterator).asJava
+ def toLocalIterator(prefetchPartitions: Boolean): JIterator[T] =
Review comment:
I named if after @holdenk 's naming in Python. If you insist, I will rename
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] SparkQA commented on pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
SparkQA commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626362222
**[Test build #122478 has started](https://amplab.cs.berkeley.edu/jenkins/job/SparkPullRequestBuilder/122478/testReport)** for PR 28488 at commit [`f43bd97`](https://github.com/apache/spark/commit/f43bd97d9c082825533033c4df0fd7f75575f210).
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-630564771
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins removed a comment on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins removed a comment on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-628317950
Merged build finished. Test FAILed.
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r424796155
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1033,22 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
- }
- partitions.indices.iterator.flatMap(i => collectPartition(i))
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+ new PrefetchingIterator(this, prefetchPartitions).flatMap(data => data)
Review comment:
we need to flatten Iterator[array[T][ to Iterator[T]
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] github-actions[bot] closed pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
github-actions[bot] closed pull request #28488:
URL: https://github.com/apache/spark/pull/28488
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422668188
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1032,101 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+
+ if (!prefetchPartitions || partitions.indices.isEmpty) {
+ def collectPartition(p: Int): Array[T] = {
+ sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ }
+ partitions.indices.iterator.flatMap(i => collectPartition(i))
+
Review comment:
fixed
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] AmplabJenkins commented on pull request #28488: [SPARK-29083][CORE] Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
AmplabJenkins commented on pull request #28488:
URL: https://github.com/apache/spark/pull/28488#issuecomment-626379048
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org
[GitHub] [spark] oleg-smith commented on a change in pull request #28488: SPARK-29083 Prefetch elements in rdd.toLocalIterator
Posted by GitBox <gi...@apache.org>.
oleg-smith commented on a change in pull request #28488:
URL: https://github.com/apache/spark/pull/28488#discussion_r422572885
##########
File path: core/src/main/scala/org/apache/spark/rdd/RDD.scala
##########
@@ -1031,20 +1032,101 @@ abstract class RDD[T: ClassTag](
Array.concat(results: _*)
}
+ def toLocalIterator : Iterator[T] = toLocalIterator(false)
+
/**
* Return an iterator that contains all of the elements in this RDD.
*
* The iterator will consume as much memory as the largest partition in this RDD.
+ * With prefetch it may consume up to the memory of the 2 largest partitions.
+ *
+ * @param prefetchPartitions If Spark should pre-fetch the next partition before it is needed.
*
* @note This results in multiple Spark jobs, and if the input RDD is the result
* of a wide transformation (e.g. join with different partitioners), to avoid
* recomputing the input RDD should be cached first.
*/
- def toLocalIterator: Iterator[T] = withScope {
- def collectPartition(p: Int): Array[T] = {
- sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ def toLocalIterator(prefetchPartitions: Boolean = false): Iterator[T] = withScope {
+
+ if (!prefetchPartitions || partitions.indices.isEmpty) {
+ def collectPartition(p: Int): Array[T] = {
+ sc.runJob(this, (iter: Iterator[T]) => iter.toArray, Seq(p)).head
+ }
+ partitions.indices.iterator.flatMap(i => collectPartition(i))
+
+ } else {
+
+ val iterator: Iterator[Array[T]] = prefetchingIterator
+ iterator.hasNext
+ iterator.flatMap(data => data)
+ }
+ }
+
+ private def prefetchingIterator: Iterator[Array[T]] = {
+
+ val partitionIterator = partitions.indices.iterator
+
+ new Iterator[Array[T]] with Serializable {
+
+ private val lock = new ReentrantLock()
+ private val ready = lock.newCondition()
+
+ private var nextResult: Array[T] = _
+ private var fetchInProgress = false
+
+ /**
+ * In addition, it prefetches next element, if it exists
+ */
+ override def hasNext(): Boolean = withLock(() => {
+ if (fetchInProgress) true
Review comment:
You mean by data? Iterator content is flattened by flatMap() in main method
----------------------------------------------------------------
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org