{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/91206257","pull_request_review_id":11716210,"id":91206257,"diff_hunk":"@@ -241,16 +241,24 @@ object LBFGS extends Logging {\n       val bcW = data.context.broadcast(w)\n       val localGradient = gradient\n \n-      val (gradientSum, lossSum) = data.treeAggregate((Vectors.zeros(n), 0.0))(\n-          seqOp = (c, v) => (c, v) match { case ((grad, loss), (label, features)) =>\n-            val l = localGradient.compute(\n-              features, label, bcW.value, grad)\n-            (grad, loss + l)\n-          },\n-          combOp = (c1, c2) => (c1, c2) match { case ((grad1, loss1), (grad2, loss2)) =>\n-            axpy(1.0, grad2, grad1)\n-            (grad1, loss1 + loss2)\n-          })\n+      val seqOp = (c: (Vector, Double), v: (Double, Vector)) =>\n+        (c, v) match {\n+          case ((grad, loss), (label, features)) =>\n+            val denseGrad = grad.toDense\n+            val l = localGradient.compute(features, label, bcW.value, denseGrad)\n+            (denseGrad, loss + l)\n+        }\n+\n+      val combOp = (c1: (Vector, Double), c2: (Vector, Double)) =>\n+        (c1, c2) match { case ((grad1, loss1), (grad2, loss2)) =>\n+          val denseGrad1 = grad1.toDense","path":"mllib/src/main/scala/org/apache/spark/mllib/optimization/LBFGS.scala","position":24,"original_position":24,"commit_id":"3b59ab283797bb8448b2b4384caa0fb12ae9fece","original_commit_id":"3b59ab283797bb8448b2b4384caa0fb12ae9fece","user":{"login":"sethah","id":7275795,"avatar_url":"https://avatars.githubusercontent.com/u/7275795?v=3","gravatar_id":"","url":"https://api.github.com/users/sethah","html_url":"https://github.com/sethah","followers_url":"https://api.github.com/users/sethah/followers","following_url":"https://api.github.com/users/sethah/following{/other_user}","gists_url":"https://api.github.com/users/sethah/gists{/gist_id}","starred_url":"https://api.github.com/users/sethah/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sethah/subscriptions","organizations_url":"https://api.github.com/users/sethah/orgs","repos_url":"https://api.github.com/users/sethah/repos","events_url":"https://api.github.com/users/sethah/events{/privacy}","received_events_url":"https://api.github.com/users/sethah/received_events","type":"User","site_admin":false},"body":"I am still pretty strongly in favor of adding a test case explicitly for this. Just make an RDD with at least one empty partition, and be sure that LBFGS will run on it.","created_at":"2016-12-07T00:49:01Z","updated_at":"2016-12-07T00:49:02Z","html_url":"https://github.com/apache/spark/pull/16037#discussion_r91206257","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/16037","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/91206257"},"html":{"href":"https://github.com/apache/spark/pull/16037#discussion_r91206257"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/16037"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/16037","id":95521887,"html_url":"https://github.com/apache/spark/pull/16037","diff_url":"https://github.com/apache/spark/pull/16037.diff","patch_url":"https://github.com/apache/spark/pull/16037.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/16037","number":16037,"state":"open","locked":false,"title":"[SPARK-18471][MLLIB] In LBFGS, avoid sending huge vectors of 0","user":{"login":"AnthonyTruchet","id":2217235,"avatar_url":"https://avatars.githubusercontent.com/u/2217235?v=3","gravatar_id":"","url":"https://api.github.com/users/AnthonyTruchet","html_url":"https://github.com/AnthonyTruchet","followers_url":"https://api.github.com/users/AnthonyTruchet/followers","following_url":"https://api.github.com/users/AnthonyTruchet/following{/other_user}","gists_url":"https://api.github.com/users/AnthonyTruchet/gists{/gist_id}","starred_url":"https://api.github.com/users/AnthonyTruchet/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/AnthonyTruchet/subscriptions","organizations_url":"https://api.github.com/users/AnthonyTruchet/orgs","repos_url":"https://api.github.com/users/AnthonyTruchet/repos","events_url":"https://api.github.com/users/AnthonyTruchet/events{/privacy}","received_events_url":"https://api.github.com/users/AnthonyTruchet/received_events","type":"User","site_admin":false},"body":"## What changes were proposed in this pull request?\r\n\r\nCostFun used to send a dense vector of zeroes as a closure in a\r\ntreeAggregate call. To avoid that, we replace treeAggregate by\r\nmapPartition + treeReduce, creating a zero vector inside the mapPartition\r\nblock in-place.\r\n\r\n## How was this patch tested?\r\n\r\nUnit test for module mllib run locally for correctness.\r\n\r\nAs for performance we run an heavy optimization on our production data (50 iterations on 128 MB weight vectors) and have seen significant decrease in terms both of runtime and container being killed by lack of off-heap memory.\r\n","created_at":"2016-11-28T15:42:14Z","updated_at":"2016-12-07T00:49:02Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b7bceaa59aa445ae3904fee193ed36084efa2921","assignee":null,"assignees":[],"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/16037/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/16037/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments{/number}","comments_url":"https://api.github.com/repos/apache/spark/issues/16037/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/3b59ab283797bb8448b2b4384caa0fb12ae9fece","head":{"label":"criteo-forks:ENG-17719-lbfgs-only","ref":"ENG-17719-lbfgs-only","sha":"3b59ab283797bb8448b2b4384caa0fb12ae9fece","user":{"login":"criteo-forks","id":9960514,"avatar_url":"https://avatars.githubusercontent.com/u/9960514?v=3","gravatar_id":"","url":"https://api.github.com/users/criteo-forks","html_url":"https://github.com/criteo-forks","followers_url":"https://api.github.com/users/criteo-forks/followers","following_url":"https://api.github.com/users/criteo-forks/following{/other_user}","gists_url":"https://api.github.com/users/criteo-forks/gists{/gist_id}","starred_url":"https://api.github.com/users/criteo-forks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/criteo-forks/subscriptions","organizations_url":"https://api.github.com/users/criteo-forks/orgs","repos_url":"https://api.github.com/users/criteo-forks/repos","events_url":"https://api.github.com/users/criteo-forks/events{/privacy}","received_events_url":"https://api.github.com/users/criteo-forks/received_events","type":"Organization","site_admin":false},"repo":{"id":63715517,"name":"spark","full_name":"criteo-forks/spark","owner":{"login":"criteo-forks","id":9960514,"avatar_url":"https://avatars.githubusercontent.com/u/9960514?v=3","gravatar_id":"","url":"https://api.github.com/users/criteo-forks","html_url":"https://github.com/criteo-forks","followers_url":"https://api.github.com/users/criteo-forks/followers","following_url":"https://api.github.com/users/criteo-forks/following{/other_user}","gists_url":"https://api.github.com/users/criteo-forks/gists{/gist_id}","starred_url":"https://api.github.com/users/criteo-forks/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/criteo-forks/subscriptions","organizations_url":"https://api.github.com/users/criteo-forks/orgs","repos_url":"https://api.github.com/users/criteo-forks/repos","events_url":"https://api.github.com/users/criteo-forks/events{/privacy}","received_events_url":"https://api.github.com/users/criteo-forks/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/criteo-forks/spark","description":"Mirror of Apache Spark forked from Apache","fork":true,"url":"https://api.github.com/repos/criteo-forks/spark","forks_url":"https://api.github.com/repos/criteo-forks/spark/forks","keys_url":"https://api.github.com/repos/criteo-forks/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/criteo-forks/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/criteo-forks/spark/teams","hooks_url":"https://api.github.com/repos/criteo-forks/spark/hooks","issue_events_url":"https://api.github.com/repos/criteo-forks/spark/issues/events{/number}","events_url":"https://api.github.com/repos/criteo-forks/spark/events","assignees_url":"https://api.github.com/repos/criteo-forks/spark/assignees{/user}","branches_url":"https://api.github.com/repos/criteo-forks/spark/branches{/branch}","tags_url":"https://api.github.com/repos/criteo-forks/spark/tags","blobs_url":"https://api.github.com/repos/criteo-forks/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/criteo-forks/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/criteo-forks/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/criteo-forks/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/criteo-forks/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/criteo-forks/spark/languages","stargazers_url":"https://api.github.com/repos/criteo-forks/spark/stargazers","contributors_url":"https://api.github.com/repos/criteo-forks/spark/contributors","subscribers_url":"https://api.github.com/repos/criteo-forks/spark/subscribers","subscription_url":"https://api.github.com/repos/criteo-forks/spark/subscription","commits_url":"https://api.github.com/repos/criteo-forks/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/criteo-forks/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/criteo-forks/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/criteo-forks/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/criteo-forks/spark/contents/{+path}","compare_url":"https://api.github.com/repos/criteo-forks/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/criteo-forks/spark/merges","archive_url":"https://api.github.com/repos/criteo-forks/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/criteo-forks/spark/downloads","issues_url":"https://api.github.com/repos/criteo-forks/spark/issues{/number}","pulls_url":"https://api.github.com/repos/criteo-forks/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/criteo-forks/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/criteo-forks/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/criteo-forks/spark/labels{/name}","releases_url":"https://api.github.com/repos/criteo-forks/spark/releases{/id}","deployments_url":"https://api.github.com/repos/criteo-forks/spark/deployments","created_at":"2016-07-19T17:47:09Z","updated_at":"2016-11-18T10:17:19Z","pushed_at":"2016-12-06T09:27:20Z","git_url":"git://github.com/criteo-forks/spark.git","ssh_url":"git@github.com:criteo-forks/spark.git","clone_url":"https://github.com/criteo-forks/spark.git","svn_url":"https://github.com/criteo-forks/spark","homepage":"","size":252838,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":1,"mirror_url":null,"open_issues_count":3,"forks":1,"open_issues":3,"watchers":0,"default_branch":"criteo-1.6"}},"base":{"label":"apache:master","ref":"master","sha":"dbf842b7a8479f9566146192ffc04421591742d5","user":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"repo":{"id":17165658,"name":"spark","full_name":"apache/spark","owner":{"login":"apache","id":47359,"avatar_url":"https://avatars.githubusercontent.com/u/47359?v=3","gravatar_id":"","url":"https://api.github.com/users/apache","html_url":"https://github.com/apache","followers_url":"https://api.github.com/users/apache/followers","following_url":"https://api.github.com/users/apache/following{/other_user}","gists_url":"https://api.github.com/users/apache/gists{/gist_id}","starred_url":"https://api.github.com/users/apache/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/apache/subscriptions","organizations_url":"https://api.github.com/users/apache/orgs","repos_url":"https://api.github.com/users/apache/repos","events_url":"https://api.github.com/users/apache/events{/privacy}","received_events_url":"https://api.github.com/users/apache/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/apache/spark","description":"Mirror of Apache Spark","fork":false,"url":"https://api.github.com/repos/apache/spark","forks_url":"https://api.github.com/repos/apache/spark/forks","keys_url":"https://api.github.com/repos/apache/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/apache/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/apache/spark/teams","hooks_url":"https://api.github.com/repos/apache/spark/hooks","issue_events_url":"https://api.github.com/repos/apache/spark/issues/events{/number}","events_url":"https://api.github.com/repos/apache/spark/events","assignees_url":"https://api.github.com/repos/apache/spark/assignees{/user}","branches_url":"https://api.github.com/repos/apache/spark/branches{/branch}","tags_url":"https://api.github.com/repos/apache/spark/tags","blobs_url":"https://api.github.com/repos/apache/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/apache/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/apache/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/apache/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/apache/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/apache/spark/languages","stargazers_url":"https://api.github.com/repos/apache/spark/stargazers","contributors_url":"https://api.github.com/repos/apache/spark/contributors","subscribers_url":"https://api.github.com/repos/apache/spark/subscribers","subscription_url":"https://api.github.com/repos/apache/spark/subscription","commits_url":"https://api.github.com/repos/apache/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/apache/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/apache/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/apache/spark/issues/comments{/number}","contents_url":"https://api.github.com/repos/apache/spark/contents/{+path}","compare_url":"https://api.github.com/repos/apache/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/apache/spark/merges","archive_url":"https://api.github.com/repos/apache/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/apache/spark/downloads","issues_url":"https://api.github.com/repos/apache/spark/issues{/number}","pulls_url":"https://api.github.com/repos/apache/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/apache/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/apache/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/apache/spark/labels{/name}","releases_url":"https://api.github.com/repos/apache/spark/releases{/id}","deployments_url":"https://api.github.com/repos/apache/spark/deployments","created_at":"2014-02-25T08:00:08Z","updated_at":"2016-12-06T21:28:29Z","pushed_at":"2016-12-07T00:40:28Z","git_url":"git://github.com/apache/spark.git","ssh_url":"git@github.com:apache/spark.git","clone_url":"https://github.com/apache/spark.git","svn_url":"https://github.com/apache/spark","homepage":null,"size":620096,"stargazers_count":10986,"watchers_count":10986,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":10262,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":458,"forks":10262,"open_issues":458,"watchers":10986,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/16037"},"html":{"href":"https://github.com/apache/spark/pull/16037"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/16037"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/16037/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/16037/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/16037/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/3b59ab283797bb8448b2b4384caa0fb12ae9fece"}}}}
{"actor":{"display_login":"sethah"}}