TE
TechEcho
Home24h TopNewestBestAskShowJobs
GitHubTwitter
Home

TechEcho

A tech news platform built with Next.js, providing global tech news and discussions.

GitHubTwitter

Home

HomeNewestBestAskShowJobs

Resources

HackerNews APIOriginal HackerNewsNext.js

© 2025 TechEcho. All rights reserved.

Why is my Rust build so slow?

298 pointsby jacobwgover 3 years ago

19 comments

twblalockover 3 years ago
This much complexity and the tribal knowledge required to bypass it, so early in the the life of a programming language, is a really bad sign.<p>It means the complexity of the problem space is not solved by the language, and the responsibility of solving it is being passed on to the users.<p>You might react to this by saying that slow build times are not a big deal. That&#x27;s a mistake -- iteration is key to productivity and other languages do it better.
评论 #29746525 未加载
评论 #29746001 未加载
评论 #29745888 未加载
评论 #29746290 未加载
评论 #29745906 未加载
评论 #29746675 未加载
评论 #29745891 未加载
评论 #29747587 未加载
评论 #29747328 未加载
评论 #29746168 未加载
PragmaticPulpover 3 years ago
I had a hunch that Warp would be the answer when I started reading.<p>I hit the same issue and worked around it the same way (boxing). My build times also went from 1-2 minutes down to a couple seconds.<p>Generally speaking, most of my Rust work has been reasonably fast on modern hardware. Waiting 3-5 seconds for incremental builds isn&#x27;t a big deal. I&#x27;ve only seen the excessive compile times with cold starts or in weird edge cases like the Warp issue.
CameronNemoover 3 years ago
This article is fairly strange. The author keeps changing settings to make the release profile more like a debug profile. Wouldn&#x27;t I want LTO for releases?<p>Also this is a really long article with a lot of cool tricks and interesting information. Like the author&#x27;s binary crate, they might consider splitting this article apart. Or at least adding a TOC!
评论 #29745957 未加载
评论 #29746020 未加载
评论 #29746040 未加载
评论 #29747656 未加载
howdydooover 3 years ago
I&#x27;ve always wondered why useful flags like `-Z timings` are not available on stable. I guess they&#x27;re worried about the output changing in a future stable release, but I don&#x27;t think anyone would expect the reports to look exactly the same and list exactly the same compilation phases, etc, for all eternity. I think that for diagnostic features, people would be just fine with a loose stability guarantee that allows the output to be improved in the future.
评论 #29745802 未加载
评论 #29745789 未加载
holodukeover 3 years ago
I came from java and compared to that even our slowest rust build time is faster than I have ever experienced in java. I remember we had a Java springboot application who had a buildtime of 8 minutes on my 2015 MacBook. I am so happy I don&#x27;t have to deal with this anymore.
评论 #29746751 未加载
评论 #29748982 未加载
评论 #29764268 未加载
评论 #29746736 未加载
评论 #29748909 未加载
_ma_rit_231over 3 years ago
The long compile times are actually one of Rust&#x27;s problems I could live with.<p>Having to depend on so many third party libs is a much bigger issue for long term maintainability and security. Also the time choosing the libs is not neglectible. At work we currently developing a mid size project (CLI and HTTP API) with Go and the standard lib is simply amazing.
评论 #29746181 未加载
评论 #29746387 未加载
menaerusover 3 years ago
Whenever I read articles like this one, it leaves me wondering in what parallel reality do I live in.<p>Or I could put it differently and say that authors making blogposts complaining about full rebuild cycle taking staggering 2 minutes live in a pink bubble.<p>Everyday reality in somewhat complex industry-placed product is 10x that if you&#x27;re lucky. More often than not it&#x27;s few hours before you&#x27;re able to build the whole thing.
评论 #29746597 未加载
评论 #29746352 未加载
swsieberover 3 years ago
Another article about rust diagnosing rust compile times: <a href="https:&#x2F;&#x2F;matklad.github.io&#x2F;2021&#x2F;09&#x2F;04&#x2F;fast-rust-builds.html" rel="nofollow">https:&#x2F;&#x2F;matklad.github.io&#x2F;2021&#x2F;09&#x2F;04&#x2F;fast-rust-builds.html</a>
charcircuitover 3 years ago
Rust&#x27;s slow compiles are such a turn off for me. Like why does it take tens of seconds to recompile when I am just changing a single number in a file? Does it really need to waste so much of my time to change a single byte in the output binary?
评论 #29744985 未加载
评论 #29745158 未加载
评论 #29744762 未加载
评论 #29745355 未加载
评论 #29745048 未加载
评论 #29744955 未加载
评论 #29744789 未加载
评论 #29744809 未加载
marmadaover 3 years ago
I loved this article! Super informative.<p>Very interesting that the author managed to hit a pathological case in rustc.
评论 #29746642 未加载
Klasiasterover 3 years ago
Instead of using sccache and turning off incremental compilation it could help to change the approach and retain the build folder from the main branch CI builds for all other builds, since both sccache and incremental compilation are kind of overlapping with incremental compilation being the integrated solution while sccache seems to be more like a workaround?
lordnachoover 3 years ago
Very long but interesting article. What&#x27;s the reason that boxing a few things shortens the compile time?
评论 #29746699 未加载
评论 #29748469 未加载
jl2718over 3 years ago
I’ve always wondered why compiled languages can’t fall back to interpreted execution for debugging.
EVa5I7bHFq9mnYKover 3 years ago
Split your code into separately compiled modules (DLLs or whatever it is these days) and minimize interface surface between those modules.
marco_craveiroover 3 years ago
This is a great post, thanks for sharing.
Ono-Sendaiover 3 years ago
tldr
评论 #29747499 未加载
flohofwoeover 3 years ago
Very interesting and detailed article how to profile the Rust toolchain, but TBH, after the reveal that the project uses several hundred dependencies my first thought was: &quot;well, there&#x27;s your problem&quot;. One thing or another will always be broken in such a complex scenario.
zenlotover 3 years ago
&quot;In another language, say, C or C++, we might write a Makefile by hand.<p>What? No. Nobody does that anymore.&quot;<p>Oh these Rustaceans or how they call themselves. Look at the gaming industry, if you&#x27;re playing any AAA&#x2F;AA game it&#x27;s most likely C++, there&#x27;s some market share on C# (where Unity is used), but still the whole gaming industry is C++, and it&#x27;s bigger than movie&#x2F;music industries combined.<p>So yes, people &quot;do that&quot;, and it&#x27;s not going to change anytime soon.
评论 #29748480 未加载
bullenover 3 years ago
Ok, I didn&#x27;t read all that but that is 100W of power.<p>My solution to be able to work on a 5W Raspberry 4 is to use C (arrays for cache misses), compile with GCC to a .so and hot-deploy that into my engine.<p>That way I have a zero dependencies engine (only stb_ttf and kuba_zip) that compiles from scratch in 30 seconds and the game .so takes ~1 second.<p>I don&#x27;t even have to use a build system or many cores to compile.<p>Simple and low power.<p>Downvotes without commenting, proves my point.