{"action":"created","comment":{"url":"https://api.github.com/repos/apache/spark/pulls/comments/24689713","id":24689713,"diff_hunk":"@@ -77,10 +77,12 @@ class CrossValidator extends Estimator[CrossValidatorModel] with CrossValidatorP\n     val splits = MLUtils.kFold(dataset.rdd, map(numFolds), 0)\n     splits.zipWithIndex.foreach { case ((training, validation), splitIndex) =>\n       val trainingDataset = sqlCtx.createDataFrame(training, schema).cache()\n-      val validationDataset = sqlCtx.createDataFrame(validation, schema).cache()\n+      val validationDataset = sqlCtx.createDataFrame(validation, schema)\n       // multi-model training\n       logDebug(s\"Train split $splitIndex with multiple sets of parameters.\")\n       val models = est.fit(trainingDataset, epm).asInstanceOf[Seq[Model[_]]]\n+      trainingDataset.unpersist()\n+      validationDataset.cache()","path":"mllib/src/main/scala/org/apache/spark/ml/tuning/CrossValidator.scala","position":10,"original_position":10,"commit_id":"c5f3265a13c39c693d1fd13d46fadff89d2ab6da","original_commit_id":"c5f3265a13c39c693d1fd13d46fadff89d2ab6da","user":{"login":"srowen","id":822522,"avatar_url":"https://avatars.githubusercontent.com/u/822522?v=3","gravatar_id":"","url":"https://api.github.com/users/srowen","html_url":"https://github.com/srowen","followers_url":"https://api.github.com/users/srowen/followers","following_url":"https://api.github.com/users/srowen/following{/other_user}","gists_url":"https://api.github.com/users/srowen/gists{/gist_id}","starred_url":"https://api.github.com/users/srowen/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/srowen/subscriptions","organizations_url":"https://api.github.com/users/srowen/orgs","repos_url":"https://api.github.com/users/srowen/repos","events_url":"https://api.github.com/users/srowen/events{/privacy}","received_events_url":"https://api.github.com/users/srowen/received_events","type":"User","site_admin":false},"body":"Seems reasonable to me, except that moving the `cache()` call here doesn't do anything. It won't be materialized until it's accessed anyway. So this reduces to making sure to properly unpersist the RDDs.","created_at":"2015-02-13T19:30:36Z","updated_at":"2015-02-13T19:30:36Z","html_url":"https://github.com/apache/spark/pull/4595#discussion_r24689713","pull_request_url":"https://api.github.com/repos/apache/spark/pulls/4595","_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/24689713"},"html":{"href":"https://github.com/apache/spark/pull/4595#discussion_r24689713"},"pull_request":{"href":"https://api.github.com/repos/apache/spark/pulls/4595"}}},"pull_request":{"url":"https://api.github.com/repos/apache/spark/pulls/4595","id":29291207,"html_url":"https://github.com/apache/spark/pull/4595","diff_url":"https://github.com/apache/spark/pull/4595.diff","patch_url":"https://github.com/apache/spark/pull/4595.patch","issue_url":"https://api.github.com/repos/apache/spark/issues/4595","number":4595,"state":"open","locked":false,"title":"[Ml] SPARK-5804 Explicitly manage cache in Crossvalidator k-fold loop","user":{"login":"petro-rudenko","id":1121987,"avatar_url":"https://avatars.githubusercontent.com/u/1121987?v=3","gravatar_id":"","url":"https://api.github.com/users/petro-rudenko","html_url":"https://github.com/petro-rudenko","followers_url":"https://api.github.com/users/petro-rudenko/followers","following_url":"https://api.github.com/users/petro-rudenko/following{/other_user}","gists_url":"https://api.github.com/users/petro-rudenko/gists{/gist_id}","starred_url":"https://api.github.com/users/petro-rudenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petro-rudenko/subscriptions","organizations_url":"https://api.github.com/users/petro-rudenko/orgs","repos_url":"https://api.github.com/users/petro-rudenko/repos","events_url":"https://api.github.com/users/petro-rudenko/events{/privacy}","received_events_url":"https://api.github.com/users/petro-rudenko/received_events","type":"User","site_admin":false},"body":"On a big dataset explicitly unpersist train and validation folds allows to load more data into memory in the next loop iteration. On my environment (single node 8Gb worker RAM, 2 GB dataset file, 3 folds for cross validation), saved more than 5 minutes.","created_at":"2015-02-13T19:22:22Z","updated_at":"2015-02-13T19:30:36Z","closed_at":null,"merged_at":null,"merge_commit_sha":"e7b45af88ef1b1440faa3633a0c8f77c6f4fb629","assignee":null,"milestone":null,"commits_url":"https://api.github.com/repos/apache/spark/pulls/4595/commits","review_comments_url":"https://api.github.com/repos/apache/spark/pulls/4595/comments","review_comment_url":"https://api.github.com/repos/apache/spark/pulls/comments/{number}","comments_url":"https://api.github.com/repos/apache/spark/issues/4595/comments","statuses_url":"https://api.github.com/repos/apache/spark/statuses/c5f3265a13c39c693d1fd13d46fadff89d2ab6da","head":{"label":"petro-rudenko:patch-2","ref":"patch-2","sha":"c5f3265a13c39c693d1fd13d46fadff89d2ab6da","user":{"login":"petro-rudenko","id":1121987,"avatar_url":"https://avatars.githubusercontent.com/u/1121987?v=3","gravatar_id":"","url":"https://api.github.com/users/petro-rudenko","html_url":"https://github.com/petro-rudenko","followers_url":"https://api.github.com/users/petro-rudenko/followers","following_url":"https://api.github.com/users/petro-rudenko/following{/other_user}","gists_url":"https://api.github.com/users/petro-rudenko/gists{/gist_id}","starred_url":"https://api.github.com/users/petro-rudenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petro-rudenko/subscriptions","organizations_url":"https://api.github.com/users/petro-rudenko/orgs","repos_url":"https://api.github.com/users/petro-rudenko/repos","events_url":"https://api.github.com/users/petro-rudenko/events{/privacy}","received_events_url":"https://api.github.com/users/petro-rudenko/received_events","type":"User","site_admin":false},"repo":{"id":30755615,"name":"spark","full_name":"petro-rudenko/spark","owner":{"login":"petro-rudenko","id":1121987,"avatar_url":"https://avatars.githubusercontent.com/u/1121987?v=3","gravatar_id":"","url":"https://api.github.com/users/petro-rudenko","html_url":"https://github.com/petro-rudenko","followers_url":"https://api.github.com/users/petro-rudenko/followers","following_url":"https://api.github.com/users/petro-rudenko/following{/other_user}","gists_url":"https://api.github.com/users/petro-rudenko/gists{/gist_id}","starred_url":"https://api.github.com/users/petro-rudenko/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/petro-rudenko/subscriptions","organizations_url":"https://api.github.com/users/petro-rudenko/orgs","repos_url":"https://api.github.com/users/petro-rudenko/repos","events_url":"https://api.github.com/users/petro-rudenko/events{/privacy}","received_events_url":"https://api.github.com/users/petro-rudenko/received_events","type":"User","site_admin":false},"private":false,"html_url":"https://github.com/petro-rudenko/spark","description":"Mirror of Apache Spark","fork":true,"url":"https://api.github.com/repos/petro-rudenko/spark","forks_url":"https://api.github.com/repos/petro-rudenko/spark/forks","keys_url":"https://api.github.com/repos/petro-rudenko/spark/keys{/key_id}","collaborators_url":"https://api.github.com/repos/petro-rudenko/spark/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/petro-rudenko/spark/teams","hooks_url":"https://api.github.com/repos/petro-rudenko/spark/hooks","issue_events_url":"https://api.github.com/repos/petro-rudenko/spark/issues/events{/number}","events_url":"https://api.github.com/repos/petro-rudenko/spark/events","assignees_url":"https://api.github.com/repos/petro-rudenko/spark/assignees{/user}","branches_url":"https://api.github.com/repos/petro-rudenko/spark/branches{/branch}","tags_url":"https://api.github.com/repos/petro-rudenko/spark/tags","blobs_url":"https://api.github.com/repos/petro-rudenko/spark/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/petro-rudenko/spark/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/petro-rudenko/spark/git/refs{/sha}","trees_url":"https://api.github.com/repos/petro-rudenko/spark/git/trees{/sha}","statuses_url":"https://api.github.com/repos/petro-rudenko/spark/statuses/{sha}","languages_url":"https://api.github.com/repos/petro-rudenko/spark/languages","stargazers_url":"https://api.github.com/repos/petro-rudenko/spark/stargazers","contributors_url":"https://api.github.com/repos/petro-rudenko/spark/contributors","subscribers_url":"https://api.github.com/repos/petro-rudenko/spark/subscribers","subscription_url":"https://api.github.com/repos/petro-rudenko/spark/subscription","commits_url":"https://api.github.com/repos/petro-rudenko/spark/commits{/sha}","git_commits_url":"https://api.github.com/repos/petro-rudenko/spark/git/commits{/sha}","comments_url":"https://api.github.com/repos/petro-rudenko/spark/comments{/number}","issue_comment_url":"https://api.github.com/repos/petro-rudenko/spark/issues/comments/{number}","contents_url":"https://api.github.com/repos/petro-rudenko/spark/contents/{+path}","compare_url":"https://api.github.com/repos/petro-rudenko/spark/compare/{base}...{head}","merges_url":"https://api.github.com/repos/petro-rudenko/spark/merges","archive_url":"https://api.github.com/repos/petro-rudenko/spark/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/petro-rudenko/spark/downloads","issues_url":"https://api.github.com/repos/petro-rudenko/spark/issues{/number}","pulls_url":"https://api.github.com/repos/petro-rudenko/spark/pulls{/number}","milestones_url":"https://api.github.com/repos/petro-rudenko/spark/milestones{/number}","notifications_url":"https://api.github.com/repos/petro-rudenko/spark/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/petro-rudenko/spark/labels{/name}","releases_url":"https://api.github.com/repos/petro-rudenko/spark/releases{/id}","created_at":"2015-02-13T12:33:31Z","updated_at":"2015-02-13T12:33:50Z","pushed_at":"2015-02-13T19:21:56Z","git_url":"git://github.com/petro-rudenko/spark.git","ssh_url":"git@github.com:petro-rudenko/spark.git","clone_url":"https://github.com/petro-rudenko/spark.git","svn_url":"https://github.com/petro-rudenko/spark","homepage":null,"size":1276045,"stargazers_count":0,"watchers_count":0,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":0,"mirror_url":null,"open_issues_count":0,"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"apache:master","ref":"master","sha":"077eec2d9dba197f51004ee4a322d0fa71424ea0","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}","created_at":"2014-02-25T08:00:08Z","updated_at":"2015-02-13T17:55:51Z","pushed_at":"2015-02-13T17:55:51Z","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":1276045,"stargazers_count":2870,"watchers_count":2870,"language":"Scala","has_issues":false,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":2515,"mirror_url":"git://git.apache.org/spark.git","open_issues_count":282,"forks":2515,"open_issues":282,"watchers":2870,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/apache/spark/pulls/4595"},"html":{"href":"https://github.com/apache/spark/pull/4595"},"issue":{"href":"https://api.github.com/repos/apache/spark/issues/4595"},"comments":{"href":"https://api.github.com/repos/apache/spark/issues/4595/comments"},"review_comments":{"href":"https://api.github.com/repos/apache/spark/pulls/4595/comments"},"review_comment":{"href":"https://api.github.com/repos/apache/spark/pulls/comments/{number}"},"commits":{"href":"https://api.github.com/repos/apache/spark/pulls/4595/commits"},"statuses":{"href":"https://api.github.com/repos/apache/spark/statuses/c5f3265a13c39c693d1fd13d46fadff89d2ab6da"}}}}