Github user MLnick commented on a diff in the pull request:
https://github.com/apache/spark/pull/17742#discussion_r114402475
--- Diff:
mllib/src/main/scala/org/apache/spark/mllib/recommendation/MatrixFactorizationModel.scala
---
@@ -276,44 +277,53 @@ object MatrixFactorizationModel extends
Loader[MatrixFactorizationModel] {
num: Int): RDD[(Int, Array[(Int, Double)])] = {
val srcBlocks = blockify(rank, srcFeatures)
val dstBlocks = blockify(rank, dstFeatures)
- val ratings = srcBlocks.cartesian(dstBlocks).flatMap {
- case ((srcIds, srcFactors), (dstIds, dstFactors)) =>
- val m = srcIds.length
- val n = dstIds.length
- val ratings = srcFactors.transpose.multiply(dstFactors)
- val output = new Array[(Int, (Int, Double))](m * n)
- var k = 0
- ratings.foreachActive { (i, j, r) =>
- output(k) = (srcIds(i), (dstIds(j), r))
- k += 1
+ /**
+ * Use dot to replace blas 3 gemm is the key approach to improve
efficiency.
+ * By this change, we can get the topK elements of each block to
reduce the GC time.
+ * Comparing with BLAS.dot, hand-written dot is high efficiency.
--- End diff --
"Compared with BLAS.dot, the hand-written version below is more efficient
than a call to the native BLAS backend and the same performance as the fallback
`F2jBLAS` backend.
---
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]