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
Rollup merge of rust-lang#136924 - Kobzol:bootstrap-tracing, r=jieyouxu
Add profiling of bootstrap commands using Chrome events
Since we now have support for tracing in bootstrap, and the execution of most commands is centralized within a few functions, it's quite trivial to also trace command execution, and visualize it using the Chrome profiler. This can be helpful both to profile what takes time in bootstrap and also to get a visual idea of what happens in a given bootstrap invocation (since the execution of external commands is usually the most interesting thing).
This is how it looks:

I first tried to use [tracing-flame](https://github.com/tokio-rs/tracing/tree/master/tracing-flame), but the output wasn't very useful, because the event/stackframe names were bootstrap code locations, instead of the command contents.
r? `@jieyouxu`
Copy file name to clipboardExpand all lines: src/doc/rustc-dev-guide/src/building/bootstrapping/debugging-bootstrap.md
+8
Original file line number
Diff line number
Diff line change
@@ -121,6 +121,14 @@ For `#[instrument]`, it's recommended to:
121
121
- Explicitly pick an instrumentation name via `name = ".."` to distinguish between e.g. `run` of different steps.
122
122
- Take care to not cause diverging behavior via tracing, e.g. building extra things only when tracing infra is enabled.
123
123
124
+
### Profiling bootstrap
125
+
126
+
You can use the `COMMAND` tracing target to trace execution of most commands spawned by bootstrap. If you also use the `BOOTSTRAP_PROFILE=1` environment variable, bootstrap will generate a Chrome JSON trace file, which can be visualized in Chrome's `chrome://tracing` page or on https://ui.perfetto.dev.
Unfortunately, because bootstrap is a `rust-analyzer.linkedProjects`, you can't ask r-a to check/build bootstrap itself with `tracing` feature enabled to get relevant completions, due to lack of support as described in <https://github.com/rust-lang/rust-analyzer/issues/8521>.
0 commit comments