{"action":"created","issue":{"url":"https://api.github.com/repos/OCamlPro/flambda-task-force/issues/160","repository_url":"https://api.github.com/repos/OCamlPro/flambda-task-force","labels_url":"https://api.github.com/repos/OCamlPro/flambda-task-force/issues/160/labels{/name}","comments_url":"https://api.github.com/repos/OCamlPro/flambda-task-force/issues/160/comments","events_url":"https://api.github.com/repos/OCamlPro/flambda-task-force/issues/160/events","html_url":"https://github.com/OCamlPro/flambda-task-force/issues/160","id":168491137,"number":160,"title":"Poor optimization of code with trivially different branches","user":{"login":"mmottl","id":1189131,"avatar_url":"https://avatars.githubusercontent.com/u/1189131?v=3","gravatar_id":"","url":"https://api.github.com/users/mmottl","html_url":"https://github.com/mmottl","followers_url":"https://api.github.com/users/mmottl/followers","following_url":"https://api.github.com/users/mmottl/following{/other_user}","gists_url":"https://api.github.com/users/mmottl/gists{/gist_id}","starred_url":"https://api.github.com/users/mmottl/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/mmottl/subscriptions","organizations_url":"https://api.github.com/users/mmottl/orgs","repos_url":"https://api.github.com/users/mmottl/repos","events_url":"https://api.github.com/users/mmottl/events{/privacy}","received_events_url":"https://api.github.com/users/mmottl/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"assignees":[],"milestone":null,"comments":11,"created_at":"2016-07-30T22:58:58Z","updated_at":"2016-08-19T19:12:00Z","closed_at":null,"body":"Consider the following two versions of file `run.ml`:\r\n\r\n### Slow\r\n```ocaml\r\nlet r = ref true\r\nlet foo f = if !r then [| f !r |] else raise Exit\r\nlet () = for _i = 1 to 500_000_000 do ignore (foo ignore) done\r\n```\r\n\r\n### fast\r\n```ocaml\r\nlet r = ref true\r\nlet foo f = if !r then [| f !r |] else [||]\r\nlet () = for _i = 1 to 500_000_000 do ignore (foo ignore) done\r\n```\r\n\r\nNote that the only, trivial difference is in the `else` branch of function `foo`.\r\n\r\nCompile these files using an Flambda-enabled compiler:\r\n```sh\r\nocamlopt -inline-max-depth 2 -inlining-report run.ml -o run.native\r\n```\r\n\r\nIf you run `time run.native`, the performance difference should be a whopping 20-30x.  Looking at the assembly, Flambda inlines `foo` in both cases, but fails to properly specialize it in the slow case.\r\n\r\nI have tried all kinds of flags and annotations, to no avail.  Interestingly, the inlining reports do not indicate any different decisions."},"comment":{"url":"https://api.github.com/repos/OCamlPro/flambda-task-force/issues/comments/241109064","html_url":"https://github.com/OCamlPro/flambda-task-force/issues/160#issuecomment-241109064","issue_url":"https://api.github.com/repos/OCamlPro/flambda-task-force/issues/160","id":241109064,"user":{"login":"chambart","id":2196625,"avatar_url":"https://avatars.githubusercontent.com/u/2196625?v=3","gravatar_id":"","url":"https://api.github.com/users/chambart","html_url":"https://github.com/chambart","followers_url":"https://api.github.com/users/chambart/followers","following_url":"https://api.github.com/users/chambart/following{/other_user}","gists_url":"https://api.github.com/users/chambart/gists{/gist_id}","starred_url":"https://api.github.com/users/chambart/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/chambart/subscriptions","organizations_url":"https://api.github.com/users/chambart/orgs","repos_url":"https://api.github.com/users/chambart/repos","events_url":"https://api.github.com/users/chambart/events{/privacy}","received_events_url":"https://api.github.com/users/chambart/received_events","type":"User","site_admin":false},"created_at":"2016-08-19T19:12:00Z","updated_at":"2016-08-19T19:12:00Z","body":"By the way, also for documentation in general for flambda, as this is quite an overwhelming task to start. I would be glad to have questions to which to answer in the form of documentation."}}
{"actor":{"display_login":"chambart"}}