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

    https://github.com/apache/spark/pull/14109#discussion_r73765222
  
    --- Diff: 
mllib/src/main/scala/org/apache/spark/ml/regression/LinearRegression.scala ---
    @@ -996,19 +1013,24 @@ private class LeastSquaresCostFun(
         featuresMean: Array[Double],
         effectiveL2regParam: Double) extends DiffFunction[BDV[Double]] {
     
    +  val bcFeaturesStd = instances.context.broadcast(featuresStd)
    +  val bcFeaturesMean = instances.context.broadcast(featuresMean)
    +
       override def calculate(coefficients: BDV[Double]): (Double, BDV[Double]) 
= {
         val coeffs = Vectors.fromBreeze(coefficients)
    +    val bcCoeffs = instances.context.broadcast(coeffs)
     
         val leastSquaresAggregator = {
           val seqOp = (c: LeastSquaresAggregator, instance: Instance) => 
c.add(instance)
           val combOp = (c1: LeastSquaresAggregator, c2: 
LeastSquaresAggregator) => c1.merge(c2)
     
           instances.treeAggregate(
    -        new LeastSquaresAggregator(coeffs, labelStd, labelMean, 
fitIntercept, featuresStd,
    -          featuresMean))(seqOp, combOp)
    +        new LeastSquaresAggregator(bcCoeffs, labelStd, labelMean, 
fitIntercept, bcFeaturesStd,
    +          bcFeaturesMean))(seqOp, combOp)
         }
     
         val totalGradientArray = leastSquaresAggregator.gradient.toArray
    +    bcCoeffs.destroy(blocking = false)
     
    --- End diff --
    
    We cannot destroy them here because they are used on every iteration. I 
just added a commit to fix this so that, after the algorithm is run, we destroy 
the broadcast variables. 


---
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 infrastruct...@apache.org or file a JIRA ticket
with INFRA.
---

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

Reply via email to