Skip to content

rustdoc: intra-doc links on blanket impls cause extra allocations #109851

Closed
@jsha

Description

@jsha

In doing some perf debugging on something else, I added eprintln output here:

if let Ok((mut href, ..)) = href(*id, cx) {

And was surprised to find that for the stm32f4 crate, building with a single feature enabled, that line of code was hit 16,000,000 times even though only 4,000 documentation pages were being generated.

It turns out that the blanket impl for Into<U> for T where U: From<T> uses an intra-doc link:

/// <code>[From]&lt;T&gt; for U</code> chooses to do.

So apparently that link gets inserted into the intra_doc_links: FxHashMap<ItemId, Vec<clean::ItemLink>> multiple times, once for each page (since every page includes this blanket impl); and then each time links() is called, it iterates through all 4,000 entries.

Metadata

Metadata

Assignees

Labels

I-compilememIssue: Problems and improvements with respect to memory usage during compilation.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

No branches or pull requests

Issue actions