Github user holdenk commented on a diff in the pull request:

    https://github.com/apache/spark/pull/11919#discussion_r58971979
  
    --- Diff: mllib/src/main/scala/org/apache/spark/ml/recommendation/ALS.scala 
---
    @@ -656,7 +656,8 @@ object ALS extends DefaultParamsReadable[ALS] with 
Logging {
             
itemFactors.setName(s"itemFactors-$iter").persist(intermediateRDDStorageLevel)
             // TODO: Generalize PeriodicGraphCheckpointer and use it here.
             if (shouldCheckpoint(iter)) {
    -          itemFactors.checkpoint() // itemFactors gets materialized in 
computeFactors.
    +          // itemFactors gets materialized in computeFactors & here.
    +          ALS.checkpointAndCleanParents(itemFactors)
    --- End diff --
    
    So digging into this I noticed checkpointing behaves a bit oddly when the 
input RDD is already materialized
    
    > scala> val rdd = sc.parallelize(1.to(10)).map(_.toString).cache()
    > rdd: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[1] at map at 
<console>:25
    > 
    > scala> rdd.checkpoint()
    > 
    > scala> rdd.count()
    > res2: Long = 10                                                           
      
    > 
    > scala> rdd.isCheckpointed
    > res3: Boolean = true
    > 
    
    However:
    
    > scala> val rdd = sc.parallelize(1.to(10)).map(_.toString).cache()
    > rdd: org.apache.spark.rdd.RDD[String] = MapPartitionsRDD[4] at map at 
<console>:25
    > 
    > scala> rdd.count()
    > res4: Long = 10
    > 
    > scala> rdd.checkpoint()
    > 
    > scala> rdd.isCheckpointed
    > res6: Boolean = false
    > 
    > scala> rdd.count()
    > res7: Long = 10
    > 
    > scala> rdd.isCheckpointed
    > res8: Boolean = false
    
    The documentation for checkpointing a bit confusing since it says 
    
    > This function must be called before any job has been executed on this RDD.
    
    yet also says
    
    > It is strongly recommended that this RDD is persisted in memory, 
otherwise saving it on a file will require recomputation.
    
    Perhaps we should also clarify the checkpointing javadoc to state:
    
    > It is strongly recommended that this RDD is marked for in memory 
persistance, otherwise saving it on a file will require recomputation.
    
    What are your thoughts?
    That being said I'm pretty sure itemFactors hasn't already been materalized 
at this point since we only mark it for persistence on L656 and there isn't any 
action before then.


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

---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]

Reply via email to