You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@spark.apache.org by Peng Cheng <pc...@uow.edu.au> on 2015/01/16 19:37:43 UTC

If an RDD appeared twice in a DAG, of which calculation is triggered by a single action, will this RDD be calculated twice?

I'm talking about RDD1 (not persisted or checkpointed) in this situation:

...(somewhere) -> RDD1 -> RDD2
                              |                |
                             V               V
                             RDD3 -> RDD4 -> Action!

To my experience the change RDD1 get recalculated is volatile, sometimes
once, sometimes twice. When calculation of this RDD is expensive (e.g.
involves using an RESTful service that charges me money), this compels me to
persist RDD1 which takes extra memory, and in case the Action! doesn't
always happen, I don't know when to unpersist it to  free those memory.

A related problem might be in $SQLContest.jsonRDD(), since the source
jsonRDD is used twice (one for schema inferring, another for data read). It
almost guarantees that the source jsonRDD is calculated twice. Has this
problem be addressed so far?



--
View this message in context: http://apache-spark-user-list.1001560.n3.nabble.com/If-an-RDD-appeared-twice-in-a-DAG-of-which-calculation-is-triggered-by-a-single-action-will-this-RDD-tp21192.html
Sent from the Apache Spark User List mailing list archive at Nabble.com.

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


Re: If an RDD appeared twice in a DAG, of which calculation is triggered by a single action, will this RDD be calculated twice?

Posted by Xuefeng Wu <be...@gmail.com>.
I think it's always twice,  could you provide some demo case for sometimes
the RDD1 calculated only once?

On Sat, Jan 17, 2015 at 2:37 AM, Peng Cheng <pc...@uow.edu.au> wrote:

> I'm talking about RDD1 (not persisted or checkpointed) in this situation:
>
> ...(somewhere) -> RDD1 -> RDD2
>                               |                |
>                              V               V
>                              RDD3 -> RDD4 -> Action!
>
> To my experience the change RDD1 get recalculated is volatile, sometimes
> once, sometimes twice. When calculation of this RDD is expensive (e.g.
> involves using an RESTful service that charges me money), this compels me
> to
> persist RDD1 which takes extra memory, and in case the Action! doesn't
> always happen, I don't know when to unpersist it to  free those memory.
>
> A related problem might be in $SQLContest.jsonRDD(), since the source
> jsonRDD is used twice (one for schema inferring, another for data read). It
> almost guarantees that the source jsonRDD is calculated twice. Has this
> problem be addressed so far?
>
>
>
> --
> View this message in context:
> http://apache-spark-user-list.1001560.n3.nabble.com/If-an-RDD-appeared-twice-in-a-DAG-of-which-calculation-is-triggered-by-a-single-action-will-this-RDD-tp21192.html
> Sent from the Apache Spark User List mailing list archive at Nabble.com.
>
> ---------------------------------------------------------------------
> To unsubscribe, e-mail: user-unsubscribe@spark.apache.org
> For additional commands, e-mail: user-help@spark.apache.org
>
>


-- 

~Yours, Xuefeng Wu/吴雪峰  敬上

Re: If an RDD appeared twice in a DAG, of which calculation is triggered by a single action, will this RDD be calculated twice?

Posted by Tobias Pfeiffer <tg...@preferred.jp>.
Hi,

On Sat, Jan 17, 2015 at 3:37 AM, Peng Cheng <pc...@uow.edu.au> wrote:

> I'm talking about RDD1 (not persisted or checkpointed) in this situation:
>
> ...(somewhere) -> RDD1 -> RDD2
>                               |                |
>                              V               V
>                              RDD3 -> RDD4 -> Action!
>
> To my experience the change RDD1 get recalculated is volatile, sometimes
> once, sometimes twice.


That should not happen if your access pattern to RDD2 and RDD3 is always
the same.

A related problem might be in $SQLContest.jsonRDD(), since the source
> jsonRDD is used twice (one for schema inferring, another for data read). It
> almost guarantees that the source jsonRDD is calculated twice. Has this
> problem be addressed so far?
>

That's exactly why schema inference is expensive. However, I am afraid in
general you have to make a decision between "store" or "recompute" (cf.
http://en.wikipedia.org/wiki/Space%E2%80%93time_tradeoff). There is no way
to avoid recomputation on each access except than storing the value, I
guess.

Tobias