[ 
https://issues.apache.org/jira/browse/SPARK-10182?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=14709416#comment-14709416
 ] 

Vyacheslav Baranov commented on SPARK-10182:
--------------------------------------------

Sorry, it was wrong spark-shell. Behaviour in master is slightly different: It 
looks like RDDs are removed from cache on GC. I had to modify the code a bit to 
reproduce the issue:

{code}
import org.apache.spark.SparkContext
import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
import org.apache.spark.mllib.linalg.Vectors
import org.apache.spark.mllib.regression.LabeledPoint

for (i <- 0 until 100) {
  val samples = Seq[LabeledPoint](
    LabeledPoint(1.0, Vectors.dense(1.0, 0.0)),
    LabeledPoint(1.0, Vectors.dense(0.0, 1.0)),
    LabeledPoint(0.0, Vectors.dense(1.0, 1.0)),
    LabeledPoint(0.0, Vectors.dense(0.0, 0.0))
  )

  val rdd = sc.parallelize(samples)

  val model = {
    new LogisticRegressionWithLBFGS()
      .setNumClasses(2)
      .run(rdd)
      .clearThreshold()
  }

}

{code}

!http://piqqin.com/img/ea6c54a1bf414828a794ca6604436d78.png!

The number of cached RDDs decreases over time. However, on real-size data when 
building cross-validated models this is real problem: useful pre-cached 
datasets are dropped from memory and replaced with these 
{{MapPartitionsRDD}}'s. With the fix I've submitted behaviour is perfectly 
fine: only one RDD is cached at a time, so pre-cached data is untouched.

> GeneralizedLinearModel doesn't unpersist cached data
> ----------------------------------------------------
>
>                 Key: SPARK-10182
>                 URL: https://issues.apache.org/jira/browse/SPARK-10182
>             Project: Spark
>          Issue Type: Bug
>          Components: MLlib
>    Affects Versions: 1.4.1
>            Reporter: Vyacheslav Baranov
>
> The problem might be reproduced in spark-shell with following code snippet:
> {code}
> import org.apache.spark.SparkContext
> import org.apache.spark.mllib.classification.LogisticRegressionWithLBFGS
> import org.apache.spark.mllib.linalg.Vectors
> import org.apache.spark.mllib.regression.LabeledPoint
> val samples = Seq[LabeledPoint](
>   LabeledPoint(1.0, Vectors.dense(1.0, 0.0)),
>   LabeledPoint(1.0, Vectors.dense(0.0, 1.0)),
>   LabeledPoint(0.0, Vectors.dense(1.0, 1.0)),
>   LabeledPoint(0.0, Vectors.dense(0.0, 0.0))
> )
> val rdd = sc.parallelize(samples)
> for (i <- 0 until 10) {
>   val model = {
>     new LogisticRegressionWithLBFGS()
>       .setNumClasses(2)
>       .run(rdd)
>       .clearThreshold()
>   }
> }
> {code}
> After code execution there are 10 {{MapPartitionsRDD}} objects on "Storage" 
> tab in Spark application UI.



--
This message was sent by Atlassian JIRA
(v6.3.4#6332)

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

Reply via email to