Skip to content
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

Enable tracebacks with line numbers by default #2412

Merged
merged 23 commits into from
Mar 4, 2025
Merged

Conversation

sveitser
Copy link
Collaborator

@sveitser sveitser commented Dec 18, 2024

  • Reenable tracebacks on dev profile
  • Add actions to the CI to trace memory usage for the jobs that sometimes get OOM killed.

Docs on cargo profiles: https://doc.rust-lang.org/cargo/reference/profiles.html#debug

Find some tradeoffs for how long compilation takes and how convenient it is to spot issues. Ideally we would have all debug info and the fastest compilation times but that's not possible.

For the CI we definitely don't need debuggers to work but it would be nice to have tracebacks because it's very time consuming to re-run it with a different profile. For local development we should IMO have tracebacks enabled by default for running tests and running the demo. Maybe it should also be possible to attach a debugger without having to re-compile after running tests.

In order to get any meaningful tracebacks we need at least debug = line-tables-only and strip = debuginfo. This gives tracebacks that don't include line numbers except the place in the code where the panic occured. I think this is what release does by default.

cargo run --profile debug-line-tables-only-strip-debuginfo  
thread 'main' panicked at src/main.rs:59:10:
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::panicking::panic
   3: core::option::unwrap_failed
   4: rust_playground::my_fun
   5: rust_playground::main
   6: core::ops::function::FnOnce::call_once

In order to get tracebacks with all files and line numbers we need strip = "none"

cargo run --profile debug-line-tables-only-strip-none 
called `Option::unwrap()` on a `None` value
stack backtrace:
   0: rust_begin_unwind
             at /rustc/4d669fb34e7db6f3825d01e4c59b7996f0531431/library/std/src/panicking.rs:681:5
   1: core::panicking::panic_fmt
             at /rustc/4d669fb34e7db6f3825d01e4c59b7996f0531431/library/core/src/panicking.rs:75:14
   2: core::panicking::panic
             at /rustc/4d669fb34e7db6f3825d01e4c59b7996f0531431/library/core/src/panicking.rs:145:5
   3: core::option::unwrap_failed
             at /rustc/4d669fb34e7db6f3825d01e4c59b7996f0531431/library/core/src/option.rs:2009:5
   4: unwrap<()>
             at /nix/store/fi8ydppm3dpk73gabvhwmsbjqwzalvzg-rust-nightly-complete-with-components-2024-12-09/lib/rustlib/src/rust/library/core/src/option.rs:972:21
   5: my_fun
             at ./src/main.rs:59:5
   6: rust_playground::main
             at ./src/main.rs:63:5
   7: core::ops::function::FnOnce::call_once
             at /nix/store/fi8ydppm3dpk73gabvhwmsbjqwzalvzg-rust-nightly-complete-with-components-2024-12-09/lib/rustlib/src/rust/library/core/src/ops/function.rs:250:5
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.

Code I used for this is

fn my_fun() {
    None.unwrap()
}

fn main() {
    my_fun()
}

@sveitser sveitser force-pushed the ma/reenable-tracebacks branch from eb2bc86 to 44d9464 Compare February 25, 2025 08:48
- Remove caching decorator since it's hard to read.
- Allow specifying pre-build and cache invalidation commands.
- Store commands in results file for easier inspection of results.
- Abort experiment if commands fail.
The customizations remove tracebacks and do not significantly speed up
compiliaton times during development in this repo. I will share an
experiment run in the PR comments.
@sveitser sveitser marked this pull request as ready for review February 25, 2025 13:39
@sveitser
Copy link
Collaborator Author

Experiment with memory usage, on linux, using mold, 64GB total RAM

image

It's not quite clear if this reduces memory usage or not but since we
strip debuginfo anyway I don't think we lose anything.
I think this will useful for debugging OOM issue on the CI because we
can go back to previous runs and look at differences.
This enables full tracebacks with line-numbers. If it fails maybe we'll
learn something thanks to the memory profiling we have now.
@sveitser sveitser changed the title Add script to benchmark compilation times Enable tracebacks with line numbers by default Mar 4, 2025
sveitser added 3 commits March 4, 2025 10:36
The script was useful but I think it could be simplified a lot by using
env vars like

- CARGO_PROFILE_<name>_SPLIT_DEBUGINFO
- CARGO_PROFILE_<name>_DEBUG
- CARGO_PROFILE_<name>_LTO

instead of editing the Cargo.toml file. At this point I don't want to
rewrite and I don't think anyone else is going to use.
@sveitser sveitser merged commit d17974e into main Mar 4, 2025
53 checks passed
@sveitser sveitser deleted the ma/reenable-tracebacks branch March 4, 2025 10:32
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants