{"id":3207,"date":"2019-07-25T14:56:24","date_gmt":"2019-07-25T03:56:24","guid":{"rendered":"http:\/\/blog.mozilla.org\/nnethercote\/?p=3207"},"modified":"2019-07-25T14:56:24","modified_gmt":"2019-07-25T03:56:24","slug":"the-rust-compiler-is-still-getting-faster","status":"publish","type":"post","link":"https:\/\/blog.mozilla.org\/nnethercote\/2019\/07\/25\/the-rust-compiler-is-still-getting-faster\/","title":{"rendered":"The Rust compiler is still getting faster"},"content":{"rendered":"<p>A key theme of the Rust 2019 roadmap is <em>maturity<\/em>. This covers a variety of topics, but a crucial one is compile times. For example, the <a href=\"https:\/\/github.com\/rust-lang\/rfcs\/blob\/master\/text\/2657-roadmap-2019.md\">roadmap itself<\/a> has the following as the first main theme for the compiler team.<\/p>\n<blockquote><p><strong>Improving &#8220;core strength&#8221;<\/strong> by lowering raw compilation times and also generating better code (which in turn can help with compilation times)<\/p><\/blockquote>\n<p>The <a href=\"https:\/\/blog.rust-lang.org\/2019\/04\/23\/roadmap.html\">roadmap explainer post<\/a> has a &#8220;polish&#8221; section that has the following as the first example.<\/p>\n<blockquote><p>Compile times and IDE support<\/p><\/blockquote>\n<p>I <a href=\"https:\/\/blog.mozilla.org\/nnethercote\/2018\/05\/17\/the-rust-compiler-is-getting-faster\/\">previously wrote about one period of improvement in Rust compiler speed<\/a>. How are things going in 2019?<\/p>\n<h3>Speed improvements in 2019<\/h3>\n<p>The following image shows changes in time taken to compile the <a href=\"https:\/\/github.com\/rust-lang-nursery\/rustc-perf\/blob\/master\/collector\/benchmarks\/README.md\">standard benchmarks<\/a> used on the <a href=\"https:\/\/perf.rust-lang.org\/\">Rust performance tracker<\/a>. It compares the compiler from 2019-01-01 with the compiler from 2019-07-24 (the most recent data at the time of writing).<\/p>\n<p><a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2019\/07\/25\/the-rust-compiler-is-still-getting-faster\/rust2019\/\" rel=\"attachment wp-att-3208\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-3208 size-full\" src=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2019.png\" alt=\"Table showing Rust compiler speedups between 2019-01-01 and 2019-07-24\" width=\"1370\" height=\"4152\" srcset=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2019.png 1370w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2019-252x764.png 252w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2019-768x2328.png 768w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2019-600x1818.png 600w\" sizes=\"(max-width: 1370px) 100vw, 1370px\" \/><\/a><\/p>\n<p>These are the <em><a href=\"https:\/\/en.wiktionary.org\/wiki\/wall_time\">wall-time<\/a><\/em> results for 29 benchmarks. There are three different build kinds measured for each one: a debug build, an optimized build, and a check build (which detects errors but doesn\u2019t generate code). For each build kind there is a mix of incremental and non-incremental runs done. The numbers for the individual runs aren&#8217;t shown here but you can see them if you <a href=\"https:\/\/perf.rust-lang.org\/compare.html?start=2019-01-01&amp;end=2019-07-23&amp;stat=wall-time\">view the results directly on the site<\/a> and click around. The &#8220;avg&#8221; column shows the average change for those runs. The &#8220;min&#8221; and &#8220;max&#8221; columns show the minimum and maximum changes among those same runs.<\/p>\n<p>The table has 261 numbers. The thing to take away is that 258 of them are negative, representing a decrease in compile time. Most of the &#8220;avg&#8221; values are in the range -20% to -40%. The &#8220;min&#8221; values (representing the best time reduction for each build kind) range from -12.4% to -51.3%. Even the &#8220;max&#8221; values (representing the worst time reduction for each build kind) are mostly better than -10%. These are pleasing results.<\/p>\n<h3>speed improvements since late 2017<\/h3>\n<p>What happens if we look further back? The image below compares the compiler from 2017-11-12 (the earliest date for which I could get data from the site) against the compiler from 2019-07-24, a period of just over 20 months.<\/p>\n<p><a href=\"http:\/\/blog.mozilla.org\/nnethercote\/2019\/07\/25\/the-rust-compiler-is-still-getting-faster\/rust2017\/\" rel=\"attachment wp-att-3209\"><img decoding=\"async\" loading=\"lazy\" class=\"alignnone wp-image-3209 size-full\" src=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2017.png\" alt=\"Table showing Rust compiler speedups between 2017-11-12 and 2019-07-24\" width=\"1376\" height=\"1780\" srcset=\"https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2017.png 1376w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2017-252x326.png 252w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2017-768x993.png 768w, https:\/\/blog.mozilla.org\/nnethercote\/files\/2019\/07\/rust2017-600x776.png 600w\" sizes=\"(max-width: 1376px) 100vw, 1376px\" \/><\/a><\/p>\n<p>These are the wall-time results for only 18 benchmarks, because the benchmark suite was smaller in late 2017. Check builds were also not measured then. You can <a href=\"https:\/\/perf.rust-lang.org\/compare.html?start=2017-11-12&amp;end=2019-07-23&amp;stat=wall-time\">view the results directly on the site<\/a>.<\/p>\n<p>My initial thought from looking at the &#8220;avg&#8221; results was &#8220;the compiler is twice as fast&#8221; but closer inspection shows that&#8217;s not quite true; the average &#8220;avg&#8221; result is 42%. (I know that averaging averages is statistically dubious, I did it just to get a rough feel.) Overall, the results are significantly better than those for 2019: the &#8220;avg&#8221; values range from -19.9% to -61.3%, and the &#8220;min&#8221; values are mostly better than -60%.<\/p>\n<p>(And don&#8217;t forget that time reduction percentages can be misleading when they get large. A 50% time reduction means the compiler is twice as fast; a 75% time reduction means the compiler is four times as fast; a 90% time reduction means the compiler is ten times as fast.)<\/p>\n<p>All this is good news. The Rust compiler has long had a reputation for being slow. I still wouldn&#8217;t describe it as fast, but it is clearly a lot faster than it used to be. Many thanks to all those who made this happen, and I would be happy to hear from anyone who wants to help continue the trend!<\/p>\n<p><em>Thanks to <a href=\"https:\/\/www.reddit.com\/user\/theZcuber\">theZcuber<\/a> for <a href=\"https:\/\/www.reddit.com\/r\/rust\/comments\/cezxjn\/compiler_speed_has_improved_3040_across_the_board\/\">a Reddit post<\/a> that was the starting point for this article.<\/em><\/p>\n","protected":false},"excerpt":{"rendered":"<p>A key theme of the Rust 2019 roadmap is maturity. This covers a variety of topics, but a crucial one is compile times. For example, the roadmap itself has the following as the first main theme for the compiler team. Improving &#8220;core strength&#8221; by lowering raw compilation times and also generating better code (which in [&hellip;]<\/p>\n","protected":false},"author":139,"featured_media":0,"comment_status":"open","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[311,16179],"tags":[],"_links":{"self":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/3207"}],"collection":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/users\/139"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/comments?post=3207"}],"version-history":[{"count":0,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/posts\/3207\/revisions"}],"wp:attachment":[{"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/media?parent=3207"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/categories?post=3207"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.mozilla.org\/nnethercote\/wp-json\/wp\/v2\/tags?post=3207"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}