Skip to content

Commit 6c9ffc7

Browse files
committed
Auto merge of #143525 - Shourya742:2025-07-06-add-profiler, r=Kobzol
Add profiler to bootstrap command This PR adds command profiling to the bootstrap command. It tracks the total execution time and records cache hits for each command. It also provides the ability to export execution result to a JSON file. Integrating this with Chrome tracing could further enhance observability. r? `@Kobzol`
2 parents ffa4063 + e394ebe commit 6c9ffc7

File tree

1 file changed

+9
-2
lines changed

1 file changed

+9
-2
lines changed

src/building/bootstrapping/debugging-bootstrap.md

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,17 @@ For `#[instrument]`, it's recommended to:
168168

169169
### Profiling bootstrap
170170

171-
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.
171+
You can set the `BOOTSTRAP_PROFILE=1` environment variable to enable command execution profiling during bootstrap. This generates:
172+
173+
* A Chrome trace file (for visualization in `chrome://tracing` or [Perfetto](https://ui.perfetto.dev)) if tracing is enabled via `BOOTSTRAP_TRACING=COMMAND=trace`
174+
* A plain-text summary file, `bootstrap-profile-{pid}.txt`, listing all commands sorted by execution time (slowest first), along with cache hits and working directories
175+
176+
Note: the `.txt` report is always generated when `BOOTSTRAP_PROFILE=1` is set — tracing is not required.
177+
178+
Example usage:
172179

173180
```bash
174-
$ BOOTSTRAP_TRACING=COMMAND=trace BOOTSTRAP_PROFILE=1 ./x build library
181+
$ BOOTSTRAP_PROFILE=1 BOOTSTRAP_TRACING=COMMAND=trace ./x build library
175182
```
176183

177184
### rust-analyzer integration?

0 commit comments

Comments
 (0)