Closed
Description
rustc
has the option to emit self-profiling data at the end of a compilation. It would be cool to include this data in the performance metrics which would allow us to see what parts of the compiler are broadly responsible for performance gains/regressions.
Running the compiler with rustc -Z self-profile -Z profile-json
will cause a self_profiler_results.json
file to be created in the working directory. The output looks like this:
[
{
"category": "Parsing",
"time_ms": 1
},
{
"category": "Expansion",
"time_ms": 2
},
{
"category": "TypeChecking",
"time_ms": 3
},
{
"category": "BorrowChecking",
"time_ms": 4
},
{
"category": "Codegen",
"time_ms": 5
},
{
"category": "Linking",
"time_ms": 6
},
{
"category": "Other",
"time_ms": 7
}
]
cc @nikomatsakis who's wanted this for a while and probably has ideas for what it should look like 😃
Activity
Mark-Simulacrum commentedon Nov 16, 2018
I discussed this around a week ago with @nikomatsakis and we arrived at the conclusion that just collecting the data would be an excellent start; I hope to have some time this next week to do just that.
Mark-Simulacrum commentedon Nov 19, 2018
I'm seeing the following results which are not valid JSON on a file just containing
fn main() {}
. Is it possible the support here isn't fully fleshed out yet? It would be good to eliminate theNaN
s and make the JSON generated be valid I think before integration into perf is done. @wesleywiser would you perhaps know if I'm doing something wrong? I'm compiling withrustc -Zprofile-json -Zself-profile t.rs
onrustc 1.32.0-nightly (13c943992 2018-11-18)
.wesleywiser commentedon Nov 20, 2018
@Mark-Simulacrum Nope, looks like you found a bug. I filed a fix here
Mark-Simulacrum commentedon Nov 25, 2018
The category labels are not currently allowed per the JSON spec; they need to be strings. I'm working on a patch now.
Rollup merge of rust-lang#56223 - Mark-Simulacrum:self-profile-json, …
Rollup merge of rust-lang#56223 - Mark-Simulacrum:self-profile-json, …
Mark-Simulacrum commentedon Dec 5, 2018
@wesleywiser Could we not print out the table if the
-Zprofile-json
is passed?wesleywiser commentedon Dec 6, 2018
@Mark-Simulacrum Absolutely!
Mark-Simulacrum commentedon Dec 6, 2018
Empirically, I'm also seeing high
Other
counts -- could we somehow dig into those? I happened to run this onlibrustc
in rustc and I see, which is quite ... unhelpful since the vast majority of the time (133 seconds) is in "other"10 remaining items