{"action":"created","issue":{"url":"https://api.github.com/repos/rust-lang/rust/issues/31849","repository_url":"https://api.github.com/repos/rust-lang/rust","labels_url":"https://api.github.com/repos/rust-lang/rust/issues/31849/labels{/name}","comments_url":"https://api.github.com/repos/rust-lang/rust/issues/31849/comments","events_url":"https://api.github.com/repos/rust-lang/rust/issues/31849/events","html_url":"https://github.com/rust-lang/rust/issues/31849","id":135839420,"number":31849,"title":"Typechecking memory use","user":{"login":"asajeffrey","id":403333,"avatar_url":"https://avatars.githubusercontent.com/u/403333?v=3","gravatar_id":"","url":"https://api.github.com/users/asajeffrey","html_url":"https://github.com/asajeffrey","followers_url":"https://api.github.com/users/asajeffrey/followers","following_url":"https://api.github.com/users/asajeffrey/following{/other_user}","gists_url":"https://api.github.com/users/asajeffrey/gists{/gist_id}","starred_url":"https://api.github.com/users/asajeffrey/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/asajeffrey/subscriptions","organizations_url":"https://api.github.com/users/asajeffrey/orgs","repos_url":"https://api.github.com/users/asajeffrey/repos","events_url":"https://api.github.com/users/asajeffrey/events{/privacy}","received_events_url":"https://api.github.com/users/asajeffrey/received_events","type":"User","site_admin":false},"labels":[{"url":"https://api.github.com/repos/rust-lang/rust/labels/A-typesystem","name":"A-typesystem","color":"d7e102"}],"state":"open","locked":false,"assignee":null,"milestone":null,"comments":12,"created_at":"2016-02-23T19:33:53Z","updated_at":"2016-03-16T13:50:57Z","closed_at":null,"body":"Typechecking the rust library at https://github.com/asajeffrey/wasm/tree/typechecking-blowup uses more than 10G of memory. The program uses a lot of nested generic traits and lifetime polymorphism. The timing details are:\r\n```\r\n$ multirust run nightly cargo rustc -- -Z time-passes\r\n   Compiling wasm v0.0.1 (file:///home/ajeffrey/github/asajeffrey/wasm)\r\ntime: 0.001; rss: 49MB\tparsing\r\ntime: 0.000; rss: 49MB\tconfiguration 1\r\ntime: 0.000; rss: 49MB\trecursion limit\r\ntime: 0.000; rss: 49MB\tgated macro checking\r\ntime: 0.000; rss: 49MB\tcrate injection\r\ntime: 0.003; rss: 54MB\tmacro loading\r\ntime: 0.000; rss: 54MB\tplugin loading\r\ntime: 0.000; rss: 54MB\tplugin registration\r\ntime: 0.025; rss: 56MB\texpansion\r\ntime: 0.001; rss: 56MB\tcomplete gated feature checking 1\r\ntime: 0.007; rss: 56MB\tconfiguration 2\r\ntime: 0.000; rss: 56MB\tgated configuration checking\r\ntime: 0.003; rss: 56MB\tmaybe building test harness\r\ntime: 0.003; rss: 56MB\tprelude injection\r\ntime: 0.000; rss: 56MB\tchecking that all macro invocations are gone\r\ntime: 0.000; rss: 56MB\tchecking for inline asm in case the target doesn't support it\r\ntime: 0.000; rss: 56MB\tcomplete gated feature checking 2\r\ntime: 0.000; rss: 56MB\tconst fn bodies and arguments\r\ntime: 0.002; rss: 56MB\tassigning node ids\r\ntime: 0.003; rss: 62MB\tlowering ast -> hir\r\ntime: 0.001; rss: 62MB\tindexing hir\r\ntime: 0.000; rss: 62MB\tattribute checking\r\ntime: 0.002; rss: 62MB\tearly lint checks\r\ntime: 0.001; rss: 60MB\texternal crate/lib resolution\r\ntime: 0.000; rss: 60MB\tlanguage item collection\r\ntime: 0.005; rss: 68MB\tresolution\r\ntime: 0.000; rss: 68MB\tlifetime resolution\r\ntime: 0.000; rss: 68MB\tlooking for entry point\r\ntime: 0.000; rss: 68MB\tlooking for plugin registrar\r\ntime: 0.001; rss: 69MB\tregion resolution\r\ntime: 0.000; rss: 69MB\tloop checking\r\ntime: 0.000; rss: 69MB\tstatic item recursion checking\r\ntime: 0.003; rss: 71MB\ttype collecting\r\ntime: 0.000; rss: 71MB\tvariance inference\r\ntime: 0.027; rss: 89MB\tcoherence checking\r\ntime: 0.014; rss: 89MB\twf checking\r\ntime: 0.004; rss: 89MB\titem-types checking\r\n```\r\nat which point the process starts using large amounts of time and memory. \r\n\r\nThe same behaviour happens with nightly-2015-12-01, so this is not part of the recent rewrite of typechecking.\r\n\r\nDiscussed on irc with @eddyb, @Manishearth and @aturon."},"comment":{"url":"https://api.github.com/repos/rust-lang/rust/issues/comments/197341132","html_url":"https://github.com/rust-lang/rust/issues/31849#issuecomment-197341132","issue_url":"https://api.github.com/repos/rust-lang/rust/issues/31849","id":197341132,"user":{"login":"nikomatsakis","id":155238,"avatar_url":"https://avatars.githubusercontent.com/u/155238?v=3","gravatar_id":"","url":"https://api.github.com/users/nikomatsakis","html_url":"https://github.com/nikomatsakis","followers_url":"https://api.github.com/users/nikomatsakis/followers","following_url":"https://api.github.com/users/nikomatsakis/following{/other_user}","gists_url":"https://api.github.com/users/nikomatsakis/gists{/gist_id}","starred_url":"https://api.github.com/users/nikomatsakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/nikomatsakis/subscriptions","organizations_url":"https://api.github.com/users/nikomatsakis/orgs","repos_url":"https://api.github.com/users/nikomatsakis/repos","events_url":"https://api.github.com/users/nikomatsakis/events{/privacy}","received_events_url":"https://api.github.com/users/nikomatsakis/received_events","type":"User","site_admin":false},"created_at":"2016-03-16T13:50:57Z","updated_at":"2016-03-16T13:50:57Z","body":"Added two more levels of parens and re-ran the test, results:\r\n\r\n```\r\nlunch-box. time rustc project-cache-issue-31849.rs\r\n\r\nreal    0m1.830s\r\nuser    0m1.761s\r\nsys     0m0.070s\r\nlunch-box. time rustc --stage0 project-cache-issue-31849.rs\r\n\r\nreal    1m43.955s\r\nuser    1m41.408s\r\nsys     0m2.428s\r\n```\r\n\r\nI hope to improve the cache and it'd be interesting to see if we can bring those numbers down, but obviously this is a big improvement."}}