Skip to content

Commit b4f9cfd

Browse files
committed
chore: remove debug info in dev builds
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) ```
1 parent 811a2ec commit b4f9cfd

File tree

2 files changed

+20
-0
lines changed

2 files changed

+20
-0
lines changed

editoast/Cargo.toml

+7
Original file line numberDiff line numberDiff line change
@@ -164,3 +164,10 @@ tempfile.workspace = true
164164

165165
[lints]
166166
workspace = true
167+
168+
[profile.dev]
169+
debug = "none"
170+
171+
[profile.dev-for-debug]
172+
inherits = "dev"
173+
debug = "full"

editoast/README.md

+13
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,19 @@ To avoid thread conflicts while accessing the database, use serial_test
4141
cargo test -- --test-threads=4
4242
```
4343

44+
# Debugging
45+
46+
:warning: For improving compilation time and therefore the developer experience, the project
47+
choose to strip out debug information by default, resulting in [about 20%
48+
shorter compilation time](https://github.com/OpenRailAssociation/osrd/pull/8579).
49+
50+
If you need to debug the project, you might want to activate the `dev-for-debug` profile
51+
which will build with debug information.
52+
53+
```
54+
cargo build --profile dev-for-debug
55+
```
56+
4457
## Useful tools
4558

4659
Here a list of components to help you in your development (see CI jobs if necessary):

0 commit comments

Comments
 (0)