rust-lang / cargo

The Rust package manager
https://doc.rust-lang.org/cargo
Apache License 2.0
12.58k stars 2.39k forks source link

Timing report of `cargo build --timings` fails to register dependency resolution timings #11819

Open MMeent opened 1 year ago

MMeent commented 1 year ago

Problem

When I run cargo build --timings on a newly checked-out branch, it automatically tries to update the crates.io indexes and download the dependencies, but the timing of this is not included in the graph. On a slow network, this can take a long time.

As it is the first item that is executed, this can lead to extremely large gaps in the timings data where according to the graphs, nothing is happening, but where we're actually downloading the latest dependencies.

Proposed Solution

It would be super useful if the report included, amongst others:

Notes

No response

weihanglo commented 1 year ago

Personal thoughts:

Some alternative solutions:

In general, I don't feel like it makes sense to have a single report for both build timing and download timing. That said, Cargo could still track time spent over network in a separate report.

epage commented 1 year ago

Another way of resolving this is if we use tracing, we could offer an unstable flag for dumping the traces (like with tracing-chrome) which would allow us a way to capture timing about the whole lifetime of the process (e.g. I want to capture Cargo.toml parsing and resolving) without having to manually track all of the data.

Maybe we'd even be able to capture the information ourselves and include it in the timings report.