-
Notifications
You must be signed in to change notification settings - Fork 12.8k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
debug_assert and debug logging shouldn't be enabled by default in optimized builds #17081
Comments
On it :) |
cargo build --release does the right thing, so it is already quite viable to use debug_assert! in the users' own packages. |
As @bluss noted, cargo already passes |
I think rustc's behaviour should be consistent with the higher-level Cargo semantics, not just Rust's own build system. |
This will be the only major reason for #8859 after my latest heap pull request lands. Debug logging causes an enormous start-up time hit on Windows due to relocations from the global state. |
This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per rust-lang#17665. It does not add a `--enable-release` flag since that would be a no-op. cc @nrc Fixes rust-lang#22390 Fixes rust-lang#17081 Partially addresses rust-lang#17665
This makes the default configuration fully optimized, with no debugging options, no llvm asserts, renames --enable-debug to --enable-debug-assertions, and adds --enable-debug as a blanket option that toggles various things, per #17665. It does not add a `--enable-release` flag since that would be a no-op. cc @nrc Fixes #22390 Fixes #17081 Partially addresses #17665
…kril Revert rust-lang#17073: Better inline preview for postfix completion See discussion on rust-lang/rust-analyzer#17077, but I strongly suspect that the changes to the `TextEdit` ranges caused VS Code's autocomplete to prefer the snippets over method completions. I explain why I think that [here](rust-lang/rust-analyzer#17077 (comment)).
…kril Revert rust-lang#17073: Better inline preview for postfix completion See discussion on rust-lang/rust-analyzer#17077, but I strongly suspect that the changes to the `TextEdit` ranges caused VS Code's autocomplete to prefer the snippets over method completions. I explain why I think that [here](rust-lang/rust-analyzer#17077 (comment)).
At the moment, using debug assertions is discouraged because it will hurt performance. In practice, no one disables assertions so they are not used:
debug_assert!
only has 11 uses in the Rust repository. It would have many more if I didn't feel I had to delete all of the assertions I used during development to avoid a 5-20% performance hit by default.It would make a lot more sense to enable them by default only in non-optimized builds where the performance hit will be dwarfed by other issues. It would be overridden by passing an explicit
--cfg
switch, and Rust's build system could just use the default. Rust developers could easily override this, but users and packagers wouldn't be given a slow / bloated build by default.This would make it acceptable to use
debug_assert!
for bounds checks in the unchecked indexing methods on slices and the very valuable jemalloc debugging assertions could also be enabled by default in an unoptimized build. Using the debug variant of mutexes rather than faster deadlocking ones is another example. There are bots building and testing with no optimizations, so there would be better testing coverage.The text was updated successfully, but these errors were encountered: