3 ms·
Doesn’t rust have incremental builds to speed up debug compilation? How slow are we talking here?
by torben-friis 9mo ago
Doesn’t rust have incremental builds to speed up debug compilation? How slow are we talking here?
- steveklabnik 9mo agoRust does have incremental rebuilds, yes. Folks have worked tirelessly to improve the speed of the Rust compiler, and it's gotten significantly faster over time. However, there are also language-level reasons why it can take longer to compile than other languages, though the initial guess of "because of the safety checks" is not one of them, those are quite fast. > How slow are we talking here? It really depends on a large number of factors. I think saying "roughly like C++" isn't totally unfair, though again, it really depends.
- sfink 9mo agoMy initial guess would be "because of the zero-cost abstractions", since I read "zero-cost" as "zero runtime cost" which implies shifting cost from runtime to compile time—as would happen with eg generics or any sort of global properties. (Uh oh, there's an em-dash, I must be an AI. I don't think I am, but that's what an AI would think.)
- steveklabnik 9mo agoI used em dashes before AI, and won't stop now :) That's sort of part of it, but it's also specific language design choices that if they were decided differently, might make things faster.
- esrauch 9mo agoPeople do have cold Rust compiles that can push up into measured in hours. Large crates often take design choices that are more compile time friendly shape. Note that C++ also has almost as large problem with compile times with large build fanouts including on templates, and it's not always realistic for incremental builds to solve either especially time burnt on linking, e.g. I believe Chromium development often uses a mode with .dlls dynamic linking instead of what they release which is all static linked exactly to speed up incremental development. The "fast" case is C not C++.
- embedding-shape 9mo ago> I believe Chromium development often uses a mode with .dlls dynamic linking instead of what they release which is all static linked exactly to speed up incremental development. The "fast" case is C not C++. Bevy, a Rust ECS framework for building games (among other things), has a similar solution by offering a build/rust "feature" that enables dynamic linking (called "dynamic_linking"). https://bevy.org/learn/quick-start/getting-started/setup/#dynamic-linking https://bevy.org/learn/quick-start/getting-started/setup/#dy...
- kibwen 9mo agoThere's no Rust codebase that takes hours to compile cold unless 1) you're compiling a massive codebase in release mode with LTO enabled, in which case, you've asked for it, 2) you've ported Doom to the type system, or 3) you're compiling on a netbook.
- dwattttt 9mo agoI'm curious if this is tracked or observed somewhere; crater runs are a huge source of information, metrics about the compilation time of crates would be quite interesting.
- estebank 9mo agoI know some large orgs have this data for internal projects. This page gives a very loose idea of how we're doing over time: https://perf.rust-lang.org/dashboard.html https://perf.rust-lang.org/dashboard.html
- esrauch 9mo agoDown and to the right is good, but the claim here is the average full release build is only 2 seconds?
- kibwen 9mo agoThose are graphs of averages from across the benchmarking suite, which you can read much more information about here: https://kobzol.github.io/rust/rustc/2023/08/18/rustc-benchmark-suite.html https://kobzol.github.io/rust/rustc/2023/08/18/rustc-benchma...