Skip to content

Include self-profiler results #299

Closed
@wesleywiser

Description

@wesleywiser
Member

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

Mark-Simulacrum commented on Nov 16, 2018

@Mark-Simulacrum
Member

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

Mark-Simulacrum commented on Nov 19, 2018

@Mark-Simulacrum
Member

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 the NaNs 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 with rustc -Zprofile-json -Zself-profile t.rs on rustc 1.32.0-nightly (13c943992 2018-11-18).

{ "category_data": [{ "category": Parsing, "time_ms": 0,
                            "query_count": 0, "query_hits": NaN }{ "category": Expansion, "time_ms": 10,
                            "query_count": 0, "query_hits": NaN }{ "category": TypeChecking, "time_ms": 1,
                            "query_count": 3444, "query_hits": 80.55 }{ "category": BorrowChecking, "time_ms": 0,
                            "query_count": 20, "query_hits": 40.00 }{ "category": Codegen, "time_ms": 3,
                            "query_count": 763, "query_hits": 65.27 }{ "category": Linking, "time_ms": 65,
                            "query_count": 64, "query_hits": 46.88 }{ "category": Other, "time_ms": 56,
                            "query_count": 13572, "query_hits": 38.73 }], "compilation_options": { "optimization_level": "No", "incremental": false } }
wesleywiser

wesleywiser commented on Nov 20, 2018

@wesleywiser
MemberAuthor

@Mark-Simulacrum Nope, looks like you found a bug. I filed a fix here

Mark-Simulacrum

Mark-Simulacrum commented on Nov 25, 2018

@Mark-Simulacrum
Member

The category labels are not currently allowed per the JSON spec; they need to be strings. I'm working on a patch now.

added a commit that references this issue on Nov 27, 2018

Rollup merge of rust-lang#56223 - Mark-Simulacrum:self-profile-json, …

8420944
added a commit that references this issue on Nov 29, 2018

Rollup merge of rust-lang#56223 - Mark-Simulacrum:self-profile-json, …

5bc98a7
Mark-Simulacrum

Mark-Simulacrum commented on Dec 5, 2018

@Mark-Simulacrum
Member

@wesleywiser Could we not print out the table if the -Zprofile-json is passed?

wesleywiser

wesleywiser commented on Dec 6, 2018

@wesleywiser
MemberAuthor

@Mark-Simulacrum Absolutely!

Mark-Simulacrum

Mark-Simulacrum commented on Dec 6, 2018

@Mark-Simulacrum
Member

Empirically, I'm also seeing high Other counts -- could we somehow dig into those? I happened to run this on librustc in rustc and I see, which is quite ... unhelpful since the vast majority of the time (133 seconds) is in "other"

Self profiling results for rustc:

| Phase            | Time (ms)      | Queries        | Hits (%) |
| ---------------- | -------------- | -------------- | -------- |
| Parsing          | 419            |                |          |
| Expansion        | 1539           |                |          |
| TypeChecking     | 31186          | 147616813      | 96.87    |
| BorrowChecking   | 6976           | 556902         | 72.80    |
| Codegen          | 71564          | 7517292        | 95.36    |
| Linking          | 2785           | 1425238        | 97.82    |
| Other            | 133209         | 96020418       | 98.11    |

Optimization level: Default
Incremental: off

10 remaining items

Loading
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      No branches or pull requests

        Participants

        @wesleywiser@nnethercote@Mark-Simulacrum

        Issue actions

          Include self-profiler results · Issue #299 · rust-lang/rustc-perf