You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
feat(cli): Allow logging to chrome traces
### What does this PR try to resolve?
> The time from executing cargo to executing rustc is 230 ms. I wonder if there’s scope for caching whatever expensive computations cargo is doing here.
*Source: https://davidlattimore.github.io/working-on-rust-iteration-time.html*
This made me curious where the time was going. I've been meaning to try out `tracing-chrome` for a while and this gave me the opportunity.
This adds `CARGO_LOG_PROFILE=<bool>` and `CARGO_LOG_PROFILE_CAPTURE_ARGS=<bool>` for enabling and controlling these trace files. These are perma-unstable env variables.
Traces can be viewed at https://ui.perfetto.dev or `chrome://tracing`.
Example: no-op `cargo check` run on `cargo-nextest`:

TODO
- [ ] Find a place to document this, see https://doc.crates.io/contrib/tests/profiling.html#internal-profiler
### How should we test and review this PR?
I looked in `config/` and didn't see a env variable parser to reuse (`get_cv_with_env` is too specialized).
### Additional information
In past projects, I've been able to use features like this to better understand code bases, bugs, etc. Hopefully this can evolve to help on-board people one day.
Most of the implementation was inspired by https://github.com/arxanas/git-branchless/blob/2923924dfbff07faa61d50771b6604cb18e64bc8/git-branchless-invoke/src/lib.rs#L55
`tracing-chrome` hasn't received updates recently, but it is also fairly quiet on Issues and PRs, so this might just be "maturity". It does have over a million downloads. It also is only enabled if explicitly opted into.
rustup added trace visualization in rust-lang/rustup#3287 using [open telemetry](https://crates.io/crates/tracing-opentelemetry) but it is behind a feature flag and and requires running a server to receive the traces.
0 commit comments