Skip to content

Almost half the time rustdoc spends on stm32h7xx-hal is in intra-doc links #78761

Closed
@jyn514

Description

@jyn514
Member
$ cargo rustdoc --features=stm32h742 -- -Z time-passes
time: 45.092; rss: 2537MB	collect-intra-doc-links
    Finished dev [unoptimized + debuginfo] target(s) in 1m 59s

rustdoc --version:

rustdoc 1.49.0-nightly (ffa2e7ae8 2020-10-24)

cc stm32-rs/stm32-rs#3

Activity

added
T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.
I-compiletimeIssue: Problems and improvements with respect to compile times.
A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by name
on Nov 5, 2020
jyn514

jyn514 commented on Nov 5, 2020

@jyn514
MemberAuthor

-Z self-profile

+-------------------------------------------------+-----------+-----------------+----------+------------+
| Item                                            | Self time | % of total time | Time     | Item count |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| collect-intra-doc-links                         | 45.67s    | 52.971          | 45.68s   | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| render_html                                     | 17.25s    | 20.008          | 17.25s   | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| collect-trait-impls                             | 12.71s    | 14.740          | 17.87s   | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| <unknown>                                       | 5.36s     | 6.221           | 7.20s    | 2122524    |
+-------------------------------------------------+-----------+-----------------+----------+------------+
| clean_crate                                     | 1.61s     | 1.873           | 2.21s    | 1          |
+-------------------------------------------------+-----------+-----------------+----------+------------+
Total cpu time: 86.209807708s
jyn514

jyn514 commented on Nov 5, 2020

@jyn514
MemberAuthor

Nearly 100% of that time is spent in get_blanket_impls.

blanket-impls

Is this even required for intra-doc links? AFAIK this is only for Send and Sync, which don't have associated items.

jyn514

jyn514 commented on Nov 5, 2020

@jyn514
MemberAuthor

... why is InferCtxtInner::new taking a quarter of the time?

jyn514

jyn514 commented on Nov 5, 2020

@jyn514
MemberAuthor

I think this could be sped up quite a bit by only considering traits that have an associated item of the right name. Then rustdoc wouldn't have to go through the trait system at all, just look at it long enough to see it wouldn't work even if it did apply to the type.

jyn514

jyn514 commented on Nov 5, 2020

@jyn514
MemberAuthor

Relevant code:

let implicit_impls = crate::clean::get_auto_trait_and_blanket_impls(cx, ty, did);

pub fn get_blanket_impls(&self, ty: Ty<'tcx>, param_env_def_id: DefId) -> Vec<Item> {

We could change get_blanket_impls to take a filter parameter, that wouldn't be too invasive I think.

added
E-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.
E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.
on Nov 5, 2020
est31

est31 commented on Nov 5, 2020

@est31
Member

It probably also doesn't help that for_each_relevant_impl simplifies the type to an extent where all generic args are erased and then iterates on all trait implementations of it:

if let Some(impls) = impls.non_blanket_impls.get(&simp) {

If you have gazillions of impl Trait for F<A1> {} .... impl Trait for F<A10000> then that's a problem :)

Reducing the number of traits this (rather expensive) search is done is a good idea!

est31

est31 commented on Nov 5, 2020

@est31
Member

I think the strategy similar to #78317 (comment) would be helpful here too, but I guess the lower hanging fruit (checking whether the trait contains the name in the first place) should be tried before.

seeplusplus

seeplusplus commented on Nov 5, 2020

@seeplusplus

Discussed in Discord with @jyn514 , I'll be trying my hand at this one 🚀
@rustbot claim

11 remaining items

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

Metadata

Metadata

Assignees

Labels

A-intra-doc-linksArea: Intra-doc links, the ability to link to items in docs by nameA-trait-systemArea: Trait systemE-mediumCall for participation: Medium difficulty. Experience needed to fix: Intermediate.E-mentorCall for participation: This issue has a mentor. Use #t-compiler/help on Zulip for discussion.I-compiletimeIssue: Problems and improvements with respect to compile times.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

    Development

    Participants

    @est31@seeplusplus@jyn514

    Issue actions

      Almost half the time rustdoc spends on `stm32h7xx-hal` is in intra-doc links · Issue #78761 · rust-lang/rust