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

[EXPERIMENTAL] bootstrap: add structured tracing to ./x test tests/ui and ./x build compiler/rustc_codegen_gcc flows #135299

Closed
wants to merge 1 commit into from

Conversation

jieyouxu
Copy link
Member

@jieyouxu jieyouxu commented Jan 9, 2025

Intended for bootstrap reading club's core infra session, to make it easier to play around with bootstrap to visualize the execution flow.

Not intended for merge because tracing + tracing_subscriber + tracing_tree are quite heavy dependencies for build times.

Example usage

$ BOOTSTRAP_LOG=bootstrap=TRACE,STEPS_TO_RUN=TRACE ./x build ./compiler/rustc_codegen_gcc/ --stage 1
$ BOOTSTRAP_LOG=bootstrap=TRACE ./x build ./compiler/rustc_codegen_gcc/ --stage 1
$ BOOTSTRAP_LOG=bootstrap=TRACE ./x test tests/ui --stage 1
$ BOOTSTRAP_LOG=bootstrap=TRACE ./x test tests/ui src/tools/run-make-support --stage 1

Screenshots

./x test tests --stage 1:
Screenshot 2025-01-10 020341

./x build compiler/rustc_codegen_gcc --stage 1:
Screenshot 2025-01-10 025543

r? @ghost

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap) labels Jan 9, 2025
@jieyouxu jieyouxu added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Jan 9, 2025
@rust-log-analyzer

This comment has been minimized.

@bjorn3
Copy link
Member

bjorn3 commented Jan 10, 2025

Maybe it would be possible to add it behind a cargo feature?

@jieyouxu
Copy link
Member Author

jieyouxu commented Jan 11, 2025

Maybe it would be possible to add it behind a cargo feature?

Possibly. All the #[instrument(..)] attribute sites will have to be gated like

#[cfg_attr(feature = "logging", instrument(...))]

but tbh I would personally want that for debugging even if that is the case.

EDIT: implemented in #135391

@jieyouxu
Copy link
Member Author

Maybe it would be possible to add it behind a cargo feature?

cf. https://rust-lang.zulipchat.com/#narrow/channel/326414-t-infra.2Fbootstrap/topic/Conditional.20.60tracing.60.20dep.3F, I also measured not gating behind conditionally and just measure the build time impact of taking on direct tracing* dependencies:

Build time measurements

Procedure

Preparation: rebase against latest master, commit 12445e0, ./x clean

The exploratory PR adds 3 (root) deps to bootstrap:

tracing = { version = "0.1.41", features = ["attributes"] }
tracing-subscriber = { version = "0.3.19", features = ["env-filter", "fmt", "registry", "std"] }
tracing-tree = "0.4.0"

Measured locally via

$ hyperfine --runs 5 --ignore-failure --prepare="./x clean" "./x build bootstrap" --show-output
  • --prepare="./x clean": clear bootstrap build cache, not counted towards bootstrap build time measurement

Before tracing* deps

Time (mean ± σ): 16.831 s ± 0.233 s [User: 38.987 s, System: 3.404 s]
Range (min … max): 16.508 s … 17.159 s 5 runs

After tracing* deps

Time (mean ± σ): 17.540 s ± 0.084 s [User: 44.758 s, System: 3.900 s]
Range (min … max): 17.457 s … 17.666 s 5 runs

Conclusion

Approximately ~0.709 seconds slower (4.21% increase in build time).

@bors
Copy link
Contributor

bors commented Jan 12, 2025

☔ The latest upstream changes (presumably #135281) made this pull request unmergeable. Please resolve the merge conflicts.

@bors bors added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Jan 12, 2025
…i` and `./x build compiler/rustc_codegen_gcc` flows

Example usages:

```bash
$ BOOTSTRAP_LOG=bootstrap=TRACE,STEPS_TO_RUN=TRACE ./x build ./compiler/rustc_codegen_gcc/ --stage 1
$ BOOTSTRAP_LOG=bootstrap=TRACE ./x build ./compiler/rustc_codegen_gcc/ --stage 1
$ BOOTSTRAP_LOG=bootstrap=TRACE ./x test tests/ui --stage 1
$ BOOTSTRAP_LOG=bootstrap=TRACE ./x test tests/ui src/tools/run-make-support --stage 1
```
jhpratt added a commit to jhpratt/rust that referenced this pull request Jan 13, 2025
…ur-ozkan

bootstrap: Implement conditional `tracing` infra

Add a conditional `tracing` setup that is gated behind `BOOTSTRAP_TRACING` env var. This `tracing` infra is implemented by:

- Introducing an optional `tracing` cargo feature in bootstrap.
- Added optional `tracing*` dependencies which are gated behind the `tracing` cargo feature.
- When `BOOTSTRAP_TRACING` is set, `bootstrap.py` will build bootstrap with `--features=tracing`.

There is a small trick here to share `BOOTSTRAP_TRACING` env var without having to add a separate env var:

- `BOOTSTRAP_TRACING=1` is not a registered `tracing` filter target, so that can be used to enable the `tracing` cargo feature yet not actually enable any tracing logs (useful for editor r-a setups without actually outputting any tracing logs).
- `BOOTSTRAP_TRACING=TRACE` and such are actually valid `tracing` filters, but that sets `BOOTSTRAP_TRACING` anyway.

Example usage: rust-lang#135299 (that experimental PR is not conditionally gated)
This PR is intentionally kept minimal to focus on the infra itself. To get actual mileage, instrumentations will need to be added to individual `Step`s and such.

r? `@onur-ozkan` (or reroll)
rust-timer added a commit to rust-lang-ci/rust that referenced this pull request Jan 13, 2025
Rollup merge of rust-lang#135391 - jieyouxu:conditional-tracing, r=onur-ozkan

bootstrap: Implement conditional `tracing` infra

Add a conditional `tracing` setup that is gated behind `BOOTSTRAP_TRACING` env var. This `tracing` infra is implemented by:

- Introducing an optional `tracing` cargo feature in bootstrap.
- Added optional `tracing*` dependencies which are gated behind the `tracing` cargo feature.
- When `BOOTSTRAP_TRACING` is set, `bootstrap.py` will build bootstrap with `--features=tracing`.

There is a small trick here to share `BOOTSTRAP_TRACING` env var without having to add a separate env var:

- `BOOTSTRAP_TRACING=1` is not a registered `tracing` filter target, so that can be used to enable the `tracing` cargo feature yet not actually enable any tracing logs (useful for editor r-a setups without actually outputting any tracing logs).
- `BOOTSTRAP_TRACING=TRACE` and such are actually valid `tracing` filters, but that sets `BOOTSTRAP_TRACING` anyway.

Example usage: rust-lang#135299 (that experimental PR is not conditionally gated)
This PR is intentionally kept minimal to focus on the infra itself. To get actual mileage, instrumentations will need to be added to individual `Step`s and such.

r? `@onur-ozkan` (or reroll)
@bors
Copy link
Contributor

bors commented Jan 13, 2025

☔ The latest upstream changes (presumably #135430) made this pull request unmergeable. Please resolve the merge conflicts.

@jieyouxu jieyouxu closed this Jan 14, 2025
Kobzol pushed a commit to Kobzol/rustc-dev-guide that referenced this pull request Jan 20, 2025
bootstrap: Implement conditional `tracing` infra

Add a conditional `tracing` setup that is gated behind `BOOTSTRAP_TRACING` env var. This `tracing` infra is implemented by:

- Introducing an optional `tracing` cargo feature in bootstrap.
- Added optional `tracing*` dependencies which are gated behind the `tracing` cargo feature.
- When `BOOTSTRAP_TRACING` is set, `bootstrap.py` will build bootstrap with `--features=tracing`.

There is a small trick here to share `BOOTSTRAP_TRACING` env var without having to add a separate env var:

- `BOOTSTRAP_TRACING=1` is not a registered `tracing` filter target, so that can be used to enable the `tracing` cargo feature yet not actually enable any tracing logs (useful for editor r-a setups without actually outputting any tracing logs).
- `BOOTSTRAP_TRACING=TRACE` and such are actually valid `tracing` filters, but that sets `BOOTSTRAP_TRACING` anyway.

Example usage: rust-lang/rust#135299 (that experimental PR is not conditionally gated)
This PR is intentionally kept minimal to focus on the infra itself. To get actual mileage, instrumentations will need to be added to individual `Step`s and such.

r? `@onur-ozkan` (or reroll)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-bootstrap Relevant to the bootstrap subteam: Rust's build system (x.py and src/bootstrap)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants