{"action":"created","issue":{"url":"https://api.github.com/repos/ejgallego/jscoq/issues/13","repository_url":"https://api.github.com/repos/ejgallego/jscoq","labels_url":"https://api.github.com/repos/ejgallego/jscoq/issues/13/labels{/name}","comments_url":"https://api.github.com/repos/ejgallego/jscoq/issues/13/comments","events_url":"https://api.github.com/repos/ejgallego/jscoq/issues/13/events","html_url":"https://github.com/ejgallego/jscoq/issues/13","id":138555810,"number":13,"title":"StackOverflow when doing large Searches","user":{"login":"ejgallego","id":7192257,"avatar_url":"https://avatars.githubusercontent.com/u/7192257?v=3","gravatar_id":"","url":"https://api.github.com/users/ejgallego","html_url":"https://github.com/ejgallego","followers_url":"https://api.github.com/users/ejgallego/followers","following_url":"https://api.github.com/users/ejgallego/following{/other_user}","gists_url":"https://api.github.com/users/ejgallego/gists{/gist_id}","starred_url":"https://api.github.com/users/ejgallego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejgallego/subscriptions","organizations_url":"https://api.github.com/users/ejgallego/orgs","repos_url":"https://api.github.com/users/ejgallego/repos","events_url":"https://api.github.com/users/ejgallego/events{/privacy}","received_events_url":"https://api.github.com/users/ejgallego/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2016-03-04T18:57:41Z","updated_at":"2016-05-02T15:40:26Z","closed_at":null,"body":"When using `Search` or `SearchAbout` with a large number of modules loaded, browsers produce a `Stack_overflow` exception.\r\n\r\nThis is unfortunate and due to `js_of_ocaml` not optimizing tail calls, see:\r\n\r\n- ocsigen/js_of_ocaml#154\r\n- ocsigen/js_of_ocaml#200\r\n- ocsigen/js_of_ocaml#357\r\n- ocsigen/js_of_ocaml#410\r\n\r\nIt will not be solved in the near future; the immediate workaround is to increase the stack size of the browser, in Chrome:\r\n\r\n`--js-flags=\"--stack-size=65536\"`\r\n\r\nallows search to work much better.\r\n\r\n### How to workaround this in Coq.\r\n\r\njs_of_ocaml asserts that:\r\n\r\n> Tail call is not optimized in general. However, mutually recursive functions are optimized: self recursive functions (when the tail calls are the function itself) are compiled using a loop. trampolines are used otherwise.\r\n\r\nSo this deserves more investigation as the code for search is straightforward.\r\n\r\nSearch likely gets into a deep recursive call by the use of `Declaremods.iter_all_segments` which calls `List.iter` and `MMap.iter`.\r\n\r\nThe likely workaround until `js_of_ocaml` is improved is indeed to chunk the iters in `Declaremod`.\r\n\r\nPatch in progress!\r\n"},"comment":{"url":"https://api.github.com/repos/ejgallego/jscoq/issues/comments/216271067","html_url":"https://github.com/ejgallego/jscoq/issues/13#issuecomment-216271067","issue_url":"https://api.github.com/repos/ejgallego/jscoq/issues/13","id":216271067,"user":{"login":"ejgallego","id":7192257,"avatar_url":"https://avatars.githubusercontent.com/u/7192257?v=3","gravatar_id":"","url":"https://api.github.com/users/ejgallego","html_url":"https://github.com/ejgallego","followers_url":"https://api.github.com/users/ejgallego/followers","following_url":"https://api.github.com/users/ejgallego/following{/other_user}","gists_url":"https://api.github.com/users/ejgallego/gists{/gist_id}","starred_url":"https://api.github.com/users/ejgallego/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/ejgallego/subscriptions","organizations_url":"https://api.github.com/users/ejgallego/orgs","repos_url":"https://api.github.com/users/ejgallego/repos","events_url":"https://api.github.com/users/ejgallego/events{/privacy}","received_events_url":"https://api.github.com/users/ejgallego/received_events","type":"User","site_admin":false},"created_at":"2016-05-02T15:40:26Z","updated_at":"2016-05-02T15:40:26Z","body":"Well, this seems to run fine now in Chrome \\ge 51 , so very good news !"}}