Optimizing by default

Yet another example of a newcomer to Rust using unoptimized builds by accident and concluding that Rust is slow.

From my Github comment:

Complaining about the status quo like this is not necessarily good – you can't see if the other option would raise similar problems with users about the even slower compilation speed.

What I mean is that you obviously don't get user stories about overlong compilation times, because currently, release is not the default.

And one more example.

Yep, it really trips people.

I agree that optimizing is a much more reasonable default. The increased compile time shouldn’t be an issue for new users, and experienced users can explicitly pass the debug flag. I also would prefer this option over noisy warnings.

Could there be a reasonable middle ground — that is, optimize, but not to the point of losing debugging information? Yes, it might make compilation a bit slower (though not as slow as --release/-O3), but it won’t trip newbies as hard. Then --debug could still disable all optimizations, while --release enables all.

But then you have a not-so-obviously incorrect solution. It works somewhat fast but not as fast as it could. The current non-solution at least makes it obvious that something is wrong, people are asking others what they are doing wrong.

2 Likes

So you want full optimization settings on by default, so that enough people complain about the compiler being slow which compels the rust team to improve the compiler. Clever. Sneaky, yes, but clever. :smile:

It should also be possible to add a local config (stored in ~/.cargo/config) that allows changing the default options for cargo build

1 Like

I don’t see why we can’t just have both cargo and rustc tell the user what they’re doing by default. If you don’t specify debug/release or an optimisation level, the compiler just says the equivalent of “oh, by the way, I’m compiling in debug mode with no optimisations.”

Silently changing the default will just shift complaints to “man, Rust takes forever to compile, even when I’m not asking for optimisation!” and we’ll be back here arguing over changing the default back.

2 Likes

Well, it’s a pretty well-regarded (if often ignored) tradition that Unix programs should be silent on success. (This only matters for rustc; cargo is already noisy of course.)

I think educating users is more important than blind adherence to tradition in the face of clear practical disadvantages.

I don’t think we need to make rustc noisy, making cargo's output more obvious in that regard should be fine.

1 Like

There’s currently a Cargo PR by @alexcrichton to have it output the used build profile (release or debug).

Here is another example of someone getting confused by this.

I created an RFC asking for rustc and cargo to produce optimized code by default.

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.