Live data from Hacker News

Why is my Rust build so slow?

fasterthanli.me

151–160 of 217 posts

Re: Why is my Rust build so slow?

#151

Earlier quoted context omitted.

The worst error message was basically no error message. After I made some big refactoring to my project, cargo would just exit with: error: could not compile `the_project`. And nothing else. No hint of what the problem is. It then took me a long time to try to comment out code here and there to find out what was causing the error. When I finally found out the problem, I took the time to fill a bug report. I don't kno…

Thank you for the great report. It indeed seems to have fallen through the cracks, with no one touching it (it's missing the T-compiler tag, which means I didn't triage it) since it was first cathegorized. I wouldn't call that lack of output representative of the experience of using rustc though, if I'm allowed to let my pride on my work flare up a bit.

Sorry, I did not mean to say that this was representative of the overall experience. On the contrary, I'm usually quite satisfied with the compiler messages. Thanks for your work!

Re: Why is my Rust build so slow?

#152

Earlier quoted context omitted.

Thank you for the great report. It indeed seems to have fallen through the cracks, with no one touching it (it's missing the T-compiler tag, which means I didn't triage it) since it was first cathegorized. I wouldn't call that lack of output representative of the experience of using rustc though, if I'm allowed to let my pride on my work flare up a bit.

Sorry, I did not mean to say that this was representative of the overall experience. On the contrary, I'm usually quite satisfied with the compiler messages. Thanks for your work!

Thank you! The "bad" thing about having high standards is that when it isn't met it is quite jarring, more so than if it were homogeneously bad or meh, and that ends up bring more frustrating.

Re: Why is my Rust build so slow?

#153
post #75

Earlier quoted context omitted.

This is more of a step-by-step deep-dive into the ways to profile, diagnose and work through the timing and performance problems. Anyone who doesn't know about many of these tools will probably find them useful (or at least useful to know that they exist) in the future. Besides, for iteration people are probably in debug, not release mode, which the article mentions is initially 19s vs 2m+. As far as I can see the ma…

Rust debug builds are also unbearably slow. I wouldn't complain that much if it was just a problems of having full optimizations on

For perf sensitive projects, I set opt-level=1 in debug for at least the dependencies.

Edit: I realized you might have meant that debug compiles still take a long time. In that case, obviously this won't help.

Re: Why is my Rust build so slow?

#154
post #45

Earlier quoted context omitted.

I'm not disagreeing, but I could cold compile a million lines of Delphi code in a few minutes on a crappy laptop more than a decade ago. Delphi managed to be both fast to compile and a fast language; of course, it's not as sophisticated or complex a language as C++ or Rust. But still...

The third axis in compiler development is safety. The compiler writer’s dilemma can be framed as: fast execution, safe execution, fast compilation — choose 2.

ADA.

This is a false(ish) dilema.

The problem of Rust is that is made with a C++ mindset. Is VERY hard to make compiler fast if it follow what C/C++ do (Go is the only evidence against!).

Is a death by thousands cut. The syntax is the FIRST and big one. How you chose it will impact all the pipeline. Then the rest...

Re: Why is my Rust build so slow?

#155
post #35

Earlier quoted context omitted.

I agree, and even as someone who holds Rust in high regard, I’m becoming increasingly frustrated by this. There doesn’t seem to be one clear root of this problem. Some of it is the language not being designed with ease of compilation in mind, unlike let’s say, to pick an extreme example, Go. Some of it is the tooling and default settings, especially around incremental compilation, linkers etc. People are working on t…

Tokio maintainer here. I've actually been spending a bunch of time recently looking in to how we can reduce Tokio's compile-times. I haven't really been able to find any big wins yet, but one thing has been pretty clear from the benchmarks: The number of dependencies of Tokio is not the problem. They all compile pretty fast and can all compile in parallel. Tokio itself takes a lot longer than the dependencies. (Excep…

Macros.

This is a major pain. I wish it get more attention (and hopefully: How about a SINGLE way to do macros? Like zig?).

Serde is another killer on compiling speed.

Re: Why is my Rust build so slow?

#156
post #105

Earlier quoted context omitted.

> 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. What languages do it best? JavaScript is a dystopia of stacked bundlers. Python dependencies and deployment is a toxic superfund wasteland. You’re not wrong that it’s a problem. But as far as I can tell build+deployment is an unsolved problem for non-hobby projects in mos…

Go is known for having really fast compilations. Almost Pascal levels of fast.

Go is also known for treating developers like cattle, so, I'll take Rust's trade-off, thanks.

Re: Why is my Rust build so slow?

#158
post #45

Earlier quoted context omitted.

I'm not disagreeing, but I could cold compile a million lines of Delphi code in a few minutes on a crappy laptop more than a decade ago. Delphi managed to be both fast to compile and a fast language; of course, it's not as sophisticated or complex a language as C++ or Rust. But still...

The third axis in compiler development is safety. The compiler writer’s dilemma can be framed as: fast execution, safe execution, fast compilation — choose 2.

I choose 3, with OCaml :-)

Re: Why is my Rust build so slow?

#159
post #105

Earlier quoted context omitted.

Go is known for having really fast compilations. Almost Pascal levels of fast.

Go is also known for treating developers like cattle, so, I'll take Rust's trade-off, thanks.

OCaml is a powerful, expressive language with generics from day one, and Go-like build speeds.

Re: Why is my Rust build so slow?

#160

Earlier quoted context omitted.

I tend to disagree with this. I've optimized build times on number of occasions on different projects, each being in the venue of multi-million LoC, and none of them benefited greatly from employing precompiled headers, which essentially should help alleviate exact this gap. Running the build with -ftime-trace almost always has shown in my experiments that the bottlenecks are either in exploding number of template in…

Compiler authors can often make compilation faster, but they have to work at it and think carefully through the problem. It has to be a focus not an afterthought. Years ago the GNAT Ada compiler authors intentionally avoided implementing precompiled headers. They instead focused on very fast lexical analysis (using a small handwritten lexer optimized for lower case letters because that was the usual case). By careful…

In general, Ada has a pretty good compilation model. It has a formalized version of C++'s physical design with spec/body separation. It's also defined grammatically to required the context clause with dependencies first before everything else in a compilation unit (subunits or library units). `separate` also allows you to separately compile those things which might change a lot.
Post reply on HN