{"action":"created","issue":{"url":"https://api.github.com/repos/kripken/emscripten/issues/3732","labels_url":"https://api.github.com/repos/kripken/emscripten/issues/3732/labels{/name}","comments_url":"https://api.github.com/repos/kripken/emscripten/issues/3732/comments","events_url":"https://api.github.com/repos/kripken/emscripten/issues/3732/events","html_url":"https://github.com/kripken/emscripten/pull/3732","id":104423286,"number":3732,"title":"Optimize optimizer eliminate stage","user":{"login":"aidanhs","id":1050652,"avatar_url":"https://avatars.githubusercontent.com/u/1050652?v=3","gravatar_id":"","url":"https://api.github.com/users/aidanhs","html_url":"https://github.com/aidanhs","followers_url":"https://api.github.com/users/aidanhs/followers","following_url":"https://api.github.com/users/aidanhs/following{/other_user}","gists_url":"https://api.github.com/users/aidanhs/gists{/gist_id}","starred_url":"https://api.github.com/users/aidanhs/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/aidanhs/subscriptions","organizations_url":"https://api.github.com/users/aidanhs/orgs","repos_url":"https://api.github.com/users/aidanhs/repos","events_url":"https://api.github.com/users/aidanhs/events{/privacy}","received_events_url":"https://api.github.com/users/aidanhs/received_events","type":"User","site_admin":false},"labels":[],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":2,"created_at":"2015-09-02T08:04:35Z","updated_at":"2015-09-02T23:12:20Z","closed_at":null,"pull_request":{"url":"https://api.github.com/repos/kripken/emscripten/pulls/3732","html_url":"https://github.com/kripken/emscripten/pull/3732","diff_url":"https://github.com/kripken/emscripten/pull/3732.diff","patch_url":"https://github.com/kripken/emscripten/pull/3732.patch"},"body":"These are just speed and style changes - there should be no output difference at all.\r\n\r\nUsing the .bc file from #3718, before:\r\n```\r\n# EMCC_DEBUG=1 emcc -O3 -o out.js slow/libemscripten_worker.bc 2>&1 | grep 'emcc step\\|total time'\r\nDEBUG    root: emcc step \"parse arguments and setup\" took 0.01 seconds\r\nDEBUG    root: emcc step \"bitcodeize inputs\" took 0.00 seconds\r\nDEBUG    root: emcc step \"process inputs\" took 0.00 seconds\r\nDEBUG    root: emcc step \"calculate system libraries\" took 0.43 seconds\r\nDEBUG    root: emcc step \"link\" took 0.63 seconds\r\nDEBUG    root: emcc step \"post-link\" took 10.19 seconds\r\nDEBUG    root: emcc step \"emscript (llvm=>js)\" took 8.62 seconds\r\nDEBUG    root: emcc step \"source transforms\" took 0.34 seconds\r\nDEBUG    root: emcc step \"js opts\" took 88.50 seconds\r\nDEBUG    root: emcc step \"final emitting\" took 0.04 seconds\r\nDEBUG    root: total time: 108.75 seconds\r\n```\r\n\r\nAfter:\r\n```\r\n# EMCC_DEBUG=1 emcc -O3 -o out.js slow/libemscripten_worker.bc 2>&1 | grep 'emcc step\\|total time'\r\nDEBUG    root: emcc step \"parse arguments and setup\" took 0.01 seconds\r\nDEBUG    root: emcc step \"bitcodeize inputs\" took 0.00 seconds\r\nDEBUG    root: emcc step \"process inputs\" took 0.00 seconds\r\nDEBUG    root: emcc step \"calculate system libraries\" took 0.43 seconds\r\nDEBUG    root: emcc step \"link\" took 0.63 seconds\r\nDEBUG    root: emcc step \"post-link\" took 10.35 seconds\r\nDEBUG    root: emcc step \"emscript (llvm=>js)\" took 9.11 seconds\r\nDEBUG    root: emcc step \"source transforms\" took 0.78 seconds\r\nDEBUG    root: emcc step \"js opts\" took 67.66 seconds\r\nDEBUG    root: emcc step \"final emitting\" took 0.05 seconds\r\nDEBUG    root: total time: 89.01 seconds\r\n```\r\n\r\nSo 20-25% optimisation speedup, 15-20% overall speedup. The optimizer tests pass, I've not yet run any others, will do so now.\r\n\r\nI've got a few other optimisations, but want to get these and the switch optimisation (#3733) fix done first."},"comment":{"url":"https://api.github.com/repos/kripken/emscripten/issues/comments/137270731","html_url":"https://github.com/kripken/emscripten/pull/3732#issuecomment-137270731","issue_url":"https://api.github.com/repos/kripken/emscripten/issues/3732","id":137270731,"user":{"login":"kripken","id":173661,"avatar_url":"https://avatars.githubusercontent.com/u/173661?v=3","gravatar_id":"","url":"https://api.github.com/users/kripken","html_url":"https://github.com/kripken","followers_url":"https://api.github.com/users/kripken/followers","following_url":"https://api.github.com/users/kripken/following{/other_user}","gists_url":"https://api.github.com/users/kripken/gists{/gist_id}","starred_url":"https://api.github.com/users/kripken/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kripken/subscriptions","organizations_url":"https://api.github.com/users/kripken/orgs","repos_url":"https://api.github.com/users/kripken/repos","events_url":"https://api.github.com/users/kripken/events{/privacy}","received_events_url":"https://api.github.com/users/kripken/received_events","type":"User","site_admin":false},"created_at":"2015-09-02T23:12:20Z","updated_at":"2015-09-02T23:12:20Z","body":"Reading the code, this all looks good (and I like the refactoring), and those numbers sound great. However, I tested on another codebase (a large game engine) and I actually see a slowdown: 7.37 seconds to 8.27.\r\n\r\nI also tested on Poppler from the test suite, with `EMCC_CORES=1` to make it slow enough to be noticeable, and I get 2.54 to 2.60 seconds, so a tiny slowdown, probably just noise.\r\n\r\nThis makes me think we should test this more, it might be that it helps the original testcase that motivated this, but harms others."}}