-
Notifications
You must be signed in to change notification settings - Fork 2.5k
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
feat(cli): Allow logging to chrome traces #13399
Conversation
r? @ehuss (rustbot has picked a reviewer for you, use r? to override) |
1736c61
to
a8b6087
Compare
What's the difference between tracing-chrome and samply, and maybe other old school dtrace flamgraph approaches? |
58d9112
to
8ff0399
Compare
This builds on
Overall, I'd say this is a lot more approachable solution for users asking the question "where is my build time going?", like those using |
Incidentally, |
src/bin/cargo/main.rs
Outdated
#[tracing::instrument(skip_all)] | ||
fn init_git(config: &Config) { |
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.
Aside: @Byron do you know if there should be or will be an equivalent to this in gitoxide? In the PR description is a trace that shows that this operation is 20% of the no-op cargo check
time. Wondering if this is something that is worth hacking around or if its a "this will go away with git2".
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.
This is an interesting case as its unclear to me how much 20% actually represent in absolute terms of time.
With that said, I looked at what init_git
is doing and I was surprised it takes time at all - it felt like it's loading some code dynamically (which is probably wrong).
gitoxide
isn't comparable with git2
as there are no globals, and everything is lazy, so I'd guess that the timing is going to be more favourable. For one, there is no equivalent to init_git
- configuration is done only when opening the repository.
I hope that helps.
☔ The latest upstream changes (presumably #13409) made this pull request unmergeable. Please resolve the merge conflicts. |
This is a follow up to rust-lang#13532 and prep for rust-lang#13399
This is a follow up to rust-lang#13532 and prep for rust-lang#13399
@bors r+ Thanks and really looking forward to this! |
☀️ Test successful - checks-actions |
Update cargo 11 commits in f772ec0224d3755ce52ac5128a80319fb2eb45d0..c3c417b85e01a1de1633317fa55e4f1a31e346d4 2024-03-01 22:57:35 +0000 to 2024-03-06 01:16:08 +0000 - fix(rustdoc-map): dedup `--extern-html-too-url` for same unit (rust-lang/cargo#13544) - test: Add test for packaging a public dependency (rust-lang/cargo#13536) - doc: Edits for git/path dependency sections (rust-lang/cargo#13341) - feat(cli): Allow logging to chrome traces (rust-lang/cargo#13399) - fix(log): Trace parameters to align with profile (rust-lang/cargo#13538) - fix(toml): Don't warn on unset Edition if only 2015 is compatible (rust-lang/cargo#13533) - fix(cli): Trace core cargo operations (rust-lang/cargo#13532) - chore: update pulldown-cmark to 0.10.0 (rust-lang/cargo#13517) - feat(add): Fallback to `rustc -v` when no MSRV is set (rust-lang/cargo#13516) - chore(ci): Ensure lockfile is respected during MSRV testing (rust-lang/cargo#13523) - feat: Use consistent colors when testing (rust-lang/cargo#13520) r? ghost
Update cargo 14 commits in f772ec0224d3755ce52ac5128a80319fb2eb45d0..a4c63fe5388beaa09e5f91196c86addab0a03580 2024-03-01 22:57:35 +0000 to 2024-03-06 22:15:17 +0000 - fix(cli): Skip tracing-chrome for platforms without 64bit atomics (rust-lang/cargo#13551) - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#13550) - fix(cli): Add traces to clarify where time is going (rust-lang/cargo#13545) - fix(rustdoc-map): dedup `--extern-html-too-url` for same unit (rust-lang/cargo#13544) - test: Add test for packaging a public dependency (rust-lang/cargo#13536) - doc: Edits for git/path dependency sections (rust-lang/cargo#13341) - feat(cli): Allow logging to chrome traces (rust-lang/cargo#13399) - fix(log): Trace parameters to align with profile (rust-lang/cargo#13538) - fix(toml): Don't warn on unset Edition if only 2015 is compatible (rust-lang/cargo#13533) - fix(cli): Trace core cargo operations (rust-lang/cargo#13532) - chore: update pulldown-cmark to 0.10.0 (rust-lang/cargo#13517) - feat(add): Fallback to `rustc -v` when no MSRV is set (rust-lang/cargo#13516) - chore(ci): Ensure lockfile is respected during MSRV testing (rust-lang/cargo#13523) - feat: Use consistent colors when testing (rust-lang/cargo#13520)
Update cargo 14 commits in f772ec0224d3755ce52ac5128a80319fb2eb45d0..a4c63fe5388beaa09e5f91196c86addab0a03580 2024-03-01 22:57:35 +0000 to 2024-03-06 22:15:17 +0000 - fix(cli): Skip tracing-chrome for platforms without 64bit atomics (rust-lang/cargo#13551) - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#13550) - fix(cli): Add traces to clarify where time is going (rust-lang/cargo#13545) - fix(rustdoc-map): dedup `--extern-html-too-url` for same unit (rust-lang/cargo#13544) - test: Add test for packaging a public dependency (rust-lang/cargo#13536) - doc: Edits for git/path dependency sections (rust-lang/cargo#13341) - feat(cli): Allow logging to chrome traces (rust-lang/cargo#13399) - fix(log): Trace parameters to align with profile (rust-lang/cargo#13538) - fix(toml): Don't warn on unset Edition if only 2015 is compatible (rust-lang/cargo#13533) - fix(cli): Trace core cargo operations (rust-lang/cargo#13532) - chore: update pulldown-cmark to 0.10.0 (rust-lang/cargo#13517) - feat(add): Fallback to `rustc -v` when no MSRV is set (rust-lang/cargo#13516) - chore(ci): Ensure lockfile is respected during MSRV testing (rust-lang/cargo#13523) - feat: Use consistent colors when testing (rust-lang/cargo#13520)
Update cargo 14 commits in f772ec0224d3755ce52ac5128a80319fb2eb45d0..a4c63fe5388beaa09e5f91196c86addab0a03580 2024-03-01 22:57:35 +0000 to 2024-03-06 22:15:17 +0000 - fix(cli): Skip tracing-chrome for platforms without 64bit atomics (rust-lang/cargo#13551) - chore: downgrade to openssl v1.1.1 (again) (rust-lang/cargo#13550) - fix(cli): Add traces to clarify where time is going (rust-lang/cargo#13545) - fix(rustdoc-map): dedup `--extern-html-too-url` for same unit (rust-lang/cargo#13544) - test: Add test for packaging a public dependency (rust-lang/cargo#13536) - doc: Edits for git/path dependency sections (rust-lang/cargo#13341) - feat(cli): Allow logging to chrome traces (rust-lang/cargo#13399) - fix(log): Trace parameters to align with profile (rust-lang/cargo#13538) - fix(toml): Don't warn on unset Edition if only 2015 is compatible (rust-lang/cargo#13533) - fix(cli): Trace core cargo operations (rust-lang/cargo#13532) - chore: update pulldown-cmark to 0.10.0 (rust-lang/cargo#13517) - feat(add): Fallback to `rustc -v` when no MSRV is set (rust-lang/cargo#13516) - chore(ci): Ensure lockfile is respected during MSRV testing (rust-lang/cargo#13523) - feat: Use consistent colors when testing (rust-lang/cargo#13520)
This is a follow up to rust-lang#13532 and prep for rust-lang#13399
What does this PR try to resolve?
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>
andCARGO_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 oncargo-nextest
:TODO
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 but it is behind a feature flag and and requires running a server to receive the traces.