Skip to content

Commit 535fc0f

Browse files
committed
Add documentation for the -Zself-profile flag
1 parent 5e7af46 commit 535fc0f

File tree

1 file changed

+47
-0
lines changed

1 file changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
# `self-profile`
2+
3+
--------------------
4+
5+
The `-Zself-profile` compiler flag enables rustc's internal profiler.
6+
When enabled, the compiler will output three binary files in the specified directory (or the current working directory if no directory is specified).
7+
These files can be analyzed by using the tools in the [`measureme`] repository.
8+
9+
To control the data recorded in the trace files, use the `-Zself-profile-events` flag.
10+
11+
For example:
12+
13+
First, run a compilation session and provide the `-Zself-profile` flag:
14+
15+
```console
16+
$ rustc --crate-name foo -Zself-profile`
17+
```
18+
19+
This will generate three files in the working directory such as:
20+
21+
- `foo-1234.events`
22+
- `foo-1234.string_data`
23+
- `foo-1234.string_index`
24+
25+
Where `foo` is the name of the crate and `1234` is the process id of the rustc process.
26+
27+
To get a summary of where the compiler is spending its time:
28+
29+
```console
30+
$ ../measureme/target/release/summarize summarize foo-1234
31+
```
32+
33+
To generate a flamegraph of the same data:
34+
35+
```console
36+
$ ../measureme/target/release/inferno foo-1234
37+
```
38+
39+
To dump the event data in a Chromium-profiler compatible format:
40+
41+
```console
42+
$ ../measureme/target/release/crox foo-1234
43+
```
44+
45+
For more information, consult the [`measureme`] documentation.
46+
47+
[`measureme`]: https://github.com/rust-lang/measureme.git

0 commit comments

Comments
 (0)