{"action":"created","comment":{"url":"https://api.github.com/repos/stripe/dagon/pulls/comments/235831388","pull_request_review_id":177789559,"id":235831388,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNTgzMTM4OA==","diff_hunk":"@@ -333,58 +453,87 @@ sealed abstract class Dag[N[_]] extends Serializable { self =>\n       throw new NoSuchElementException(msg)\n     }\n \n-  /**\n-   * This is only called by ensure\n-   *\n-   * Note, Expr must never be a Var\n-   */\n-  private def addExp[T](node: N[T], exp: Expr[N, T]): (Dag[N], Id[T]) = {\n-    require(!exp.isVar)\n-    val nodeId = Id.next[T]()\n-    (copy(id2Exp = idToExp.updated(nodeId, exp)), nodeId)\n-  }\n-\n   /**\n    * ensure the given literal node is present in the Dag\n    * Note: it is important that at each moment, each node has\n    * at most one id in the graph. Put another way, for all\n    * Id[T] in the graph evaluate(id) is distinct.\n    */\n-  protected def ensure[T](node: N[T]): (Dag[N], Id[T]) =\n-    find(node) match {\n+  protected def ensure[T](node: N[T]): (Dag[N], Id[T]) = {\n+    val lit = toLiteral(node)\n+    try ensureFast(lit)\n+    catch {\n+      case _: Throwable => //StackOverflowError should work, but not on scala.js\n+        ensureRec(lit).result\n+    }\n+  }\n+\n+  /*\n+   * This does recursion on the stack, which is faster, but can overflow\n+   */\n+  protected def ensureFast[T](lit: Literal[N, T]): (Dag[N], Id[T]) =","path":"core/src/main/scala/com/stripe/dagon/Dag.scala","position":405,"original_position":405,"commit_id":"359e639c5f2fe8d6a2a95f03b849a5ccd6a8bc1a","original_commit_id":"359e639c5f2fe8d6a2a95f03b849a5ccd6a8bc1a","user":{"login":"dieu","id":47102,"node_id":"MDQ6VXNlcjQ3MTAy","avatar_url":"https://avatars3.githubusercontent.com/u/47102?v=4","gravatar_id":"","url":"https://api.github.com/users/dieu","html_url":"https://github.com/dieu","followers_url":"https://api.github.com/users/dieu/followers","following_url":"https://api.github.com/users/dieu/following{/other_user}","gists_url":"https://api.github.com/users/dieu/gists{/gist_id}","starred_url":"https://api.github.com/users/dieu/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/dieu/subscriptions","organizations_url":"https://api.github.com/users/dieu/orgs","repos_url":"https://api.github.com/users/dieu/repos","events_url":"https://api.github.com/users/dieu/events{/privacy}","received_events_url":"https://api.github.com/users/dieu/received_events","type":"User","site_admin":false},"body":"`ensure` basically converting `Literal` to `Expr`, right? what's do you think to remove the layer of `Expr` and merge `Literal` and `Expr` together? ","created_at":"2018-11-23T00:10:14Z","updated_at":"2018-11-23T00:10:14Z","html_url":"https://github.com/stripe/dagon/pull/27#discussion_r235831388","pull_request_url":"https://api.github.com/repos/stripe/dagon/pulls/27","author_association":"NONE","_links":{"self":{"href":"https://api.github.com/repos/stripe/dagon/pulls/comments/235831388"},"html":{"href":"https://github.com/stripe/dagon/pull/27#discussion_r235831388"},"pull_request":{"href":"https://api.github.com/repos/stripe/dagon/pulls/27"}}},"pull_request":{"url":"https://api.github.com/repos/stripe/dagon/pulls/27","id":231740030,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMxNzQwMDMw","html_url":"https://github.com/stripe/dagon/pull/27","diff_url":"https://github.com/stripe/dagon/pull/27.diff","patch_url":"https://github.com/stripe/dagon/pull/27.patch","issue_url":"https://api.github.com/repos/stripe/dagon/issues/27","number":27,"state":"open","locked":false,"title":"Add a test with a large DAG","user":{"login":"johnynek","id":67958,"node_id":"MDQ6VXNlcjY3OTU4","avatar_url":"https://avatars0.githubusercontent.com/u/67958?v=4","gravatar_id":"","url":"https://api.github.com/users/johnynek","html_url":"https://github.com/johnynek","followers_url":"https://api.github.com/users/johnynek/followers","following_url":"https://api.github.com/users/johnynek/following{/other_user}","gists_url":"https://api.github.com/users/johnynek/gists{/gist_id}","starred_url":"https://api.github.com/users/johnynek/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/johnynek/subscriptions","organizations_url":"https://api.github.com/users/johnynek/orgs","repos_url":"https://api.github.com/users/johnynek/repos","events_url":"https://api.github.com/users/johnynek/events{/privacy}","received_events_url":"https://api.github.com/users/johnynek/received_events","type":"User","site_admin":false},"body":"@dieu take a look...\r\n\r\nThis reproduces the stack overflow we have seen in scalding.","created_at":"2018-11-17T17:27:54Z","updated_at":"2018-11-23T00:10:14Z","closed_at":null,"merged_at":null,"merge_commit_sha":"9890a08ca36d1b3f1926f675e865ba3b31c73ce1","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/stripe/dagon/pulls/27/commits","review_comments_url":"https://api.github.com/repos/stripe/dagon/pulls/27/comments","review_comment_url":"https://api.github.com/repos/stripe/dagon/pulls/comments{/number}","comments_url":"https://api.github.com/repos/stripe/dagon/issues/27/comments","statuses_url":"https://api.github.com/repos/stripe/dagon/statuses/359e639c5f2fe8d6a2a95f03b849a5ccd6a8bc1a","head":{"label":"stripe:oscar/test_big_dag","ref":"oscar/test_big_dag","sha":"359e639c5f2fe8d6a2a95f03b849a5ccd6a8bc1a","user":{"login":"stripe","id":856813,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NjgxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/856813?v=4","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"repo":{"id":101003058,"node_id":"MDEwOlJlcG9zaXRvcnkxMDEwMDMwNTg=","name":"dagon","full_name":"stripe/dagon","private":false,"owner":{"login":"stripe","id":856813,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NjgxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/856813?v=4","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stripe/dagon","description":"Tools for rewriting and optimizing DAGs (directed-acyclic graphs) in Scala","fork":false,"url":"https://api.github.com/repos/stripe/dagon","forks_url":"https://api.github.com/repos/stripe/dagon/forks","keys_url":"https://api.github.com/repos/stripe/dagon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stripe/dagon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stripe/dagon/teams","hooks_url":"https://api.github.com/repos/stripe/dagon/hooks","issue_events_url":"https://api.github.com/repos/stripe/dagon/issues/events{/number}","events_url":"https://api.github.com/repos/stripe/dagon/events","assignees_url":"https://api.github.com/repos/stripe/dagon/assignees{/user}","branches_url":"https://api.github.com/repos/stripe/dagon/branches{/branch}","tags_url":"https://api.github.com/repos/stripe/dagon/tags","blobs_url":"https://api.github.com/repos/stripe/dagon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stripe/dagon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stripe/dagon/git/refs{/sha}","trees_url":"https://api.github.com/repos/stripe/dagon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stripe/dagon/statuses/{sha}","languages_url":"https://api.github.com/repos/stripe/dagon/languages","stargazers_url":"https://api.github.com/repos/stripe/dagon/stargazers","contributors_url":"https://api.github.com/repos/stripe/dagon/contributors","subscribers_url":"https://api.github.com/repos/stripe/dagon/subscribers","subscription_url":"https://api.github.com/repos/stripe/dagon/subscription","commits_url":"https://api.github.com/repos/stripe/dagon/commits{/sha}","git_commits_url":"https://api.github.com/repos/stripe/dagon/git/commits{/sha}","comments_url":"https://api.github.com/repos/stripe/dagon/comments{/number}","issue_comment_url":"https://api.github.com/repos/stripe/dagon/issues/comments{/number}","contents_url":"https://api.github.com/repos/stripe/dagon/contents/{+path}","compare_url":"https://api.github.com/repos/stripe/dagon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stripe/dagon/merges","archive_url":"https://api.github.com/repos/stripe/dagon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stripe/dagon/downloads","issues_url":"https://api.github.com/repos/stripe/dagon/issues{/number}","pulls_url":"https://api.github.com/repos/stripe/dagon/pulls{/number}","milestones_url":"https://api.github.com/repos/stripe/dagon/milestones{/number}","notifications_url":"https://api.github.com/repos/stripe/dagon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stripe/dagon/labels{/name}","releases_url":"https://api.github.com/repos/stripe/dagon/releases{/id}","deployments_url":"https://api.github.com/repos/stripe/dagon/deployments","created_at":"2017-08-22T00:19:29Z","updated_at":"2018-11-22T11:31:33Z","pushed_at":"2018-11-22T03:54:47Z","git_url":"git://github.com/stripe/dagon.git","ssh_url":"git@github.com:stripe/dagon.git","clone_url":"https://github.com/stripe/dagon.git","svn_url":"https://github.com/stripe/dagon","homepage":null,"size":205,"stargazers_count":110,"watchers_count":110,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":3,"open_issues":4,"watchers":110,"default_branch":"master"}},"base":{"label":"stripe:master","ref":"master","sha":"616eb76a6c61c82ba44b4406f2c3e64c4116ae99","user":{"login":"stripe","id":856813,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NjgxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/856813?v=4","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"repo":{"id":101003058,"node_id":"MDEwOlJlcG9zaXRvcnkxMDEwMDMwNTg=","name":"dagon","full_name":"stripe/dagon","private":false,"owner":{"login":"stripe","id":856813,"node_id":"MDEyOk9yZ2FuaXphdGlvbjg1NjgxMw==","avatar_url":"https://avatars1.githubusercontent.com/u/856813?v=4","gravatar_id":"","url":"https://api.github.com/users/stripe","html_url":"https://github.com/stripe","followers_url":"https://api.github.com/users/stripe/followers","following_url":"https://api.github.com/users/stripe/following{/other_user}","gists_url":"https://api.github.com/users/stripe/gists{/gist_id}","starred_url":"https://api.github.com/users/stripe/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/stripe/subscriptions","organizations_url":"https://api.github.com/users/stripe/orgs","repos_url":"https://api.github.com/users/stripe/repos","events_url":"https://api.github.com/users/stripe/events{/privacy}","received_events_url":"https://api.github.com/users/stripe/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/stripe/dagon","description":"Tools for rewriting and optimizing DAGs (directed-acyclic graphs) in Scala","fork":false,"url":"https://api.github.com/repos/stripe/dagon","forks_url":"https://api.github.com/repos/stripe/dagon/forks","keys_url":"https://api.github.com/repos/stripe/dagon/keys{/key_id}","collaborators_url":"https://api.github.com/repos/stripe/dagon/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/stripe/dagon/teams","hooks_url":"https://api.github.com/repos/stripe/dagon/hooks","issue_events_url":"https://api.github.com/repos/stripe/dagon/issues/events{/number}","events_url":"https://api.github.com/repos/stripe/dagon/events","assignees_url":"https://api.github.com/repos/stripe/dagon/assignees{/user}","branches_url":"https://api.github.com/repos/stripe/dagon/branches{/branch}","tags_url":"https://api.github.com/repos/stripe/dagon/tags","blobs_url":"https://api.github.com/repos/stripe/dagon/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/stripe/dagon/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/stripe/dagon/git/refs{/sha}","trees_url":"https://api.github.com/repos/stripe/dagon/git/trees{/sha}","statuses_url":"https://api.github.com/repos/stripe/dagon/statuses/{sha}","languages_url":"https://api.github.com/repos/stripe/dagon/languages","stargazers_url":"https://api.github.com/repos/stripe/dagon/stargazers","contributors_url":"https://api.github.com/repos/stripe/dagon/contributors","subscribers_url":"https://api.github.com/repos/stripe/dagon/subscribers","subscription_url":"https://api.github.com/repos/stripe/dagon/subscription","commits_url":"https://api.github.com/repos/stripe/dagon/commits{/sha}","git_commits_url":"https://api.github.com/repos/stripe/dagon/git/commits{/sha}","comments_url":"https://api.github.com/repos/stripe/dagon/comments{/number}","issue_comment_url":"https://api.github.com/repos/stripe/dagon/issues/comments{/number}","contents_url":"https://api.github.com/repos/stripe/dagon/contents/{+path}","compare_url":"https://api.github.com/repos/stripe/dagon/compare/{base}...{head}","merges_url":"https://api.github.com/repos/stripe/dagon/merges","archive_url":"https://api.github.com/repos/stripe/dagon/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/stripe/dagon/downloads","issues_url":"https://api.github.com/repos/stripe/dagon/issues{/number}","pulls_url":"https://api.github.com/repos/stripe/dagon/pulls{/number}","milestones_url":"https://api.github.com/repos/stripe/dagon/milestones{/number}","notifications_url":"https://api.github.com/repos/stripe/dagon/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/stripe/dagon/labels{/name}","releases_url":"https://api.github.com/repos/stripe/dagon/releases{/id}","deployments_url":"https://api.github.com/repos/stripe/dagon/deployments","created_at":"2017-08-22T00:19:29Z","updated_at":"2018-11-22T11:31:33Z","pushed_at":"2018-11-22T03:54:47Z","git_url":"git://github.com/stripe/dagon.git","ssh_url":"git@github.com:stripe/dagon.git","clone_url":"https://github.com/stripe/dagon.git","svn_url":"https://github.com/stripe/dagon","homepage":null,"size":205,"stargazers_count":110,"watchers_count":110,"language":"Scala","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":3,"mirror_url":null,"archived":false,"open_issues_count":4,"license":{"key":"apache-2.0","name":"Apache License 2.0","spdx_id":"Apache-2.0","url":"https://api.github.com/licenses/apache-2.0","node_id":"MDc6TGljZW5zZTI="},"forks":3,"open_issues":4,"watchers":110,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/stripe/dagon/pulls/27"},"html":{"href":"https://github.com/stripe/dagon/pull/27"},"issue":{"href":"https://api.github.com/repos/stripe/dagon/issues/27"},"comments":{"href":"https://api.github.com/repos/stripe/dagon/issues/27/comments"},"review_comments":{"href":"https://api.github.com/repos/stripe/dagon/pulls/27/comments"},"review_comment":{"href":"https://api.github.com/repos/stripe/dagon/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/stripe/dagon/pulls/27/commits"},"statuses":{"href":"https://api.github.com/repos/stripe/dagon/statuses/359e639c5f2fe8d6a2a95f03b849a5ccd6a8bc1a"}},"author_association":"COLLABORATOR"}}
{"actor":{"display_login":"dieu"}}