-
Notifications
You must be signed in to change notification settings - Fork 46
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
chore: remove debug info in dev builds #8579
Conversation
Codecov ReportAll modified and coverable lines are covered by tests ✅
❗ Your organization needs to install the Codecov GitHub app to enable full functionality. Additional details and impacted files@@ Coverage Diff @@
## dev #8579 +/- ##
============================================
+ Coverage 36.87% 36.90% +0.03%
Complexity 2175 2175
============================================
Files 1279 1279
Lines 118883 118972 +89
Branches 3188 3188
============================================
+ Hits 43836 43910 +74
- Misses 73162 73177 +15
Partials 1885 1885
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Sentry. |
Hm, I'm a bit sad to see the stack trace go away in case of panics… Would |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great ! 🚀
On my machine (macOS, M1 Pro, 16Gb), I get a 16% improvement :)
Benchmark 1: cargo build --workspace (branch = dev)
Time (mean ± σ): 117.344 s ± 0.804 s [User: 496.570 s, System: 57.728 s]
Range (min … max): 116.027 s … 118.518 s 10 runs
Benchmark 2: cargo build --workspace (branch = wsl/editoast/chore/no-debug-info)
Time (mean ± σ): 100.904 s ± 0.705 s [User: 417.180 s, System: 54.106 s]
Range (min … max): 99.896 s … 102.012 s 10 runs
Summary
cargo build --workspace (branch = wsl/editoast/chore/no-debug-info) ran
1.16 ± 0.01 times faster than cargo build --workspace (branch = dev)
@emersion I agree, the stack traces on panic are indeed useful. From https://doc.rust-lang.org/cargo/reference/profiles.html#debug:
I'll re-run the benchmark this afternoon with this setting (now it's lunch time 😁). |
Only 10% improvement with backtrace info:
|
Just so we know what the impact is, here is a simple program tested with all the debug levels (with The program is simply. fn crash() {
panic!("Hello, world!");
}
fn main() {
crash()
} With default debug level
With debug level
With debug level
So for producing stacktrace, |
Good to see that "none" isn't literally "nothing at all good luck out there", ie. still includes function names at least.
It depends. If there are multiple ways that a function could panic (e.g. multiple unwrap calls) then there is no way to tell which part is causing the panic. It seems like there is no way to override the [profile.dev-with-debug]
inherits = "dev"
debug = true |
+1 on the other dev profile. Unless I'm reading it wrong fn panik(yes: bool) {
if yes { panic!("oh"); }
}
fn main() {
panik(false); // did the panic originate from here
panik(true); // or here?
} I'd suggest going for |
First, most of the time, we do not debug our binaries: debug information is useless, until we need it for debugging. But it affects our compile time significantly (and that is more frequent than debugging). Therefore, I propose to remove the debug information by default, and those who needs to debug the binary, can always turn it on again when needed. Removing debug information is configured with `debug` option https://doc.rust-lang.org/cargo/reference/profiles.html#debug. A small benchmark for total build time, using [`hyperfine`](https://github.com/sharkdp/hyperfine), shows a 21% improvement in compile times. ``` ❯ hyperfine \ --parameter-list branch 'dev,wsl/editoast/chore/no-debug-info' \ --prepare 'git switch {branch} && cargo clean' \ 'cargo build --workspace' Benchmark 1: cargo build --workspace (branch = dev) Time (mean ± σ): 246.746 s ± 7.407 s [User: 1196.443 s, System: 60.608 s] Range (min … max): 227.791 s … 256.083 s 10 runs Warning: Statistical outliers were detected. Consider re-running this benchmark on a quiet system without any interferences from other programs. It might help to use the '--warmup' or '--prepare' options. Benchmark 2: cargo build --workspace (branch = wsl/editoast/chore/no-debug-info) Time (mean ± σ): 203.227 s ± 1.618 s [User: 939.154 s, System: 51.359 s] Range (min … max): 201.509 s … 206.476 s 10 runs Summary cargo build --workspace (branch = wsl/editoast/chore/no-debug-info) ran 1.21 ± 0.04 times faster than cargo build --workspace (branch = dev) ```
9bf77f6
to
4aec917
Compare
Thank you for all the feedback and suggestions. I created a new profile for debug information. I also added some documentation about that profile. Tell me if you like it. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice!
(Alternatively, we could only disable debug info when building inside Docker.) |
4aec917
to
b4f9cfd
Compare
In the end, I put |
b4f9cfd
to
1462895
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
🚀
First, most of the time, we do not debug our binaries: debug information is useless, until we need it for debugging. But it affects our compile time significantly (and that is more frequent than debugging).
Therefore, I propose to remove the debug information by default, and those who needs to debug the binary, can always turn it on again when needed. Removing debug information is configured with
debug
option https://doc.rust-lang.org/cargo/reference/profiles.html#debug.A small benchmark for total build time,
using
hyperfine
, shows a 21% improvement in compile times.