Github user srowen commented on a diff in the pull request: https://github.com/apache/spark/pull/23048#discussion_r233866690 --- Diff: mllib-local/src/main/scala/org/apache/spark/ml/linalg/Vectors.scala --- @@ -370,14 +370,19 @@ object Vectors { case (v1: DenseVector, v2: SparseVector) => squaredDistance = sqdist(v2, v1) - case (DenseVector(vv1), DenseVector(vv2)) => - var kv = 0 + case (DenseVector(vv1), DenseVector(vv2)) => { val sz = vv1.length - while (kv < sz) { - val score = vv1(kv) - vv2(kv) - squaredDistance += score * score - kv += 1 + @annotation.tailrec --- End diff -- Why would tail recursion be faster? I can't really imagine why. A small method can get JITted, but the overhead of the method calls is still got to be much higher than an increment and compare. I'd like to understand how it was benchmarked and what the difference is
--- --------------------------------------------------------------------- To unsubscribe, e-mail: reviews-unsubscr...@spark.apache.org For additional commands, e-mail: reviews-h...@spark.apache.org