Skip to content

A third of the time rustdoc takes to document windows-rs is <unknown> #81251

@jyn514

Description

@jyn514
Member

I tried this code: microsoft/windows-docs-rs@3371c03

I expected to see this happen: cargo rustdoc -- -Z self-profile shows where the 50 minutes are being spent.

Instead, this happened: Rustdoc completely loses 20 of the 50 minutes and gives up.

Here's the top 6 items from summarize summarize:

+-------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                            | Self time | % of total time | Time     | Item count |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| <unknown>                                       | 653.09s   | 36.998          | 1336.82s | 24718096   |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| resolve_crate                                   | 540.19s   | 30.602          | 540.19s  | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| render_html                                     | 384.93s   | 21.807          | 386.88s  | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| get_blanket_impls                               | 66.06s    | 3.742           | 76.22s   | 45080      |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| expand_crate                                    | 30.12s    | 1.706           | 30.13s   | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+

Note that <unknown> is at the top.
cc microsoft/windows-rs#420, #74590 (comment)

Meta

rustdoc --version: rustdoc 1.51.0-nightly (a4cbb44ae 2021-01-20)

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
C-bugCategory: This is a bug.
A-self-profileArea: Self-profiling feature of the compiler
on Jan 21, 2021
jyn514

jyn514 commented on Jan 21, 2021

@jyn514
MemberAuthor

I am still baffled what this could be. item_types_checking is clearly being measured, and the only places I see <unknown> are

So I don't know what this could possibly be.

jyn514

jyn514 commented on Jan 21, 2021

@jyn514
MemberAuthor

I can also reproduce on rust-lang/cargo@4de00d2, which works on linux and is overall easier to build.

> cargo +stage1 rustdoc -- -Z self-profile
> summarize summarize cargo-30689.mm_profdata
+-------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                            | Self time | % of total time | Time     | Item count |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| expand_crate                                    | 971.54ms  | 18.035          | 991.92ms | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| <unknown>                                       | 884.97ms  | 16.428          | 2.93s    | 709329     |
+-------------------------------------------------+-----------+-----------------+----------+------------+

There are no similar <unknown> queries when running rustc directly.

jyn514

jyn514 commented on Jan 21, 2021

@jyn514
MemberAuthor

This is definitely not from

// after this point, they'll show up as "<unknown>" in self-profiling data.
because RUSTC_LOG=rustc_interface doesn't show "Post-codegen" anyway.

jyn514

jyn514 commented on Jan 22, 2021

@jyn514
MemberAuthor

I've only skimmed the PR but I think we should not block merging this with resolving the unknown issue. We've seen that before in other profiles so it's probably another instance of the existing issue. I hope to have some time this week to look into it.

@wesleywiser do you remember where you've seen this before?

wesleywiser

wesleywiser commented on Jan 22, 2021

@wesleywiser
Member

I had an theory that I ran by @jyn514 and they're testing it out: rustdoc never calls start_codegen() and therefore alloc_self_profile_query_strings() is never called which means the <unknown> events are actually every query in rustc!

This seems to hold if we look at the summarize output for a rustdoc self-profile like this one. As far as I can tell, the only events listed are ones timed using the generic_activity() API which uses a different code path to store the event label. From what I can tell, there are no queries at all listed.

jyn514

jyn514 commented on Jan 22, 2021

@jyn514
MemberAuthor

@wesleywiser that did it! unknown doesn't show up at all any more :)

+-------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                            | Self time | % of total time | Time     | Item count |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| expand_crate                                    | 697.97ms  | 15.614          | 711.88ms | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| get_blanket_impls                               | 615.38ms  | 13.766          | 707.27ms | 472        |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| render_item                                     | 499.50ms  | 11.174          | 503.16ms | 510        |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| build_extern_trait_impl                         | 415.08ms  | 9.286           | 714.64ms | 22356      |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| get_auto_trait_impls                            | 272.80ms  | 6.103           | 314.81ms | 472        |
+-------------------------------------------------+-----------+-----------------+----------+------------+
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

    A-self-profileArea: Self-profiling feature of the compilerC-bugCategory: This is a bug.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.WG-compiler-performanceWorking group: Compiler Performance

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

      Development

      Participants

      @wesleywiser@jyn514

      Issue actions

        A third of the time rustdoc takes to document windows-rs is `<unknown>` · Issue #81251 · rust-lang/rust