[ https://issues.apache.org/jira/browse/SPARK-19746?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel
]
DB Tsai reassigned SPARK-19746:
-------------------------------
Assignee: Seth Hendrickson
> LogisticAggregator is inefficient in indexing
> ---------------------------------------------
>
> Key: SPARK-19746
> URL: https://issues.apache.org/jira/browse/SPARK-19746
> Project: Spark
> Issue Type: Improvement
> Components: ML
> Affects Versions: 2.1.0
> Reporter: Seth Hendrickson
> Assignee: Seth Hendrickson
> Fix For: 2.2.0
>
>
> The following code occurs in the `LogisticAggregator.add` method, which is a performance
critical path.
> {code}
> val localCoefficients = bcCoefficients.value
> features.foreachActive { (index, value) =>
> val stdValue = value / localFeaturesStd(index)
> var j = 0
> while (j < numClasses) {
> margins(j) += localCoefficients(index * numClasses + j) * stdValue
> j += 1
> }
> }
> {code}
> `llocalCoefficients(index * numClasses + j)` calls the `apply` method on `Vector`, which
dispatches to `asBreeze(index * numClasses + j)` which creates a new Breeze vector, and then
indexes it. This is very inefficient, creates a lot of unnecessary garbage, and we can avoid
it by indexing the underlying array.
--
This message was sent by Atlassian JIRA
(v6.3.15#6346)
---------------------------------------------------------------------
To unsubscribe, e-mail: issues-unsubscribe@spark.apache.org
For additional commands, e-mail: issues-help@spark.apache.org
|