Skip to content

[perf-only] rustdoc: Unconditionally enable --generate-link-to-definition and lazily typeck nested bodies with a cache - #156355

Closed
fmease wants to merge 8 commits into
rust-lang:mainfrom
fmease:rustdoc-ltd-lazy-cached-typck
Closed

[perf-only] rustdoc: Unconditionally enable --generate-link-to-definition and lazily typeck nested bodies with a cache#156355
fmease wants to merge 8 commits into
rust-lang:mainfrom
fmease:rustdoc-ltd-lazy-cached-typck

Conversation

@fmease

@fmeasefmease commented May 9, 2026

Copy link
Copy Markdown
Member

@fmeasefmease added S-experimental Status: Ongoing experiment that does not require reviewing and won't be merged in its current state. rla-silenced Silences rust-log-analyzer postings to the PR it's added on. labels May 9, 2026
@rustbotrustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. T-rustdoc Relevant to the rustdoc team, which will review and decide on the PR/issue. T-rustdoc-frontend Relevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output. labels May 9, 2026
@fmease

Copy link
Copy Markdown
MemberAuthor

@bors try parent=fb0a5a5a9c892b351f34263d6d84da9dde72871a @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 9, 2026
rust-borsBot pushed a commit that referenced this pull request May 9, 2026
[perf-only] rustdoc: Unconditionally enable `--generate-link-to-definition` and lazily typeck nested bodies with a cache
Comment on lines +108 to +110
//FIXME: Allegedly, we might actually typeck code here that's cfg'ed out
// which could lead to errors getting reported which would be wild.
// Re-audit this! Do we have any tests demonstrating this?

@fmeasefmeaseMay 9, 2026

Copy link
Copy Markdown
MemberAuthor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

(it doesn't affect cfg'ed out code, it just means we're type-checking bodies which we usually don't do; it means we can't document std)

View changes since the review

@fmeasefmease removed the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label May 9, 2026
@rust-bors

rust-borsBot commented May 9, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 69577e4 (69577e4cf0bb04efb4088734375caed2632e4c70, parent: fb0a5a5a9c892b351f34263d6d84da9dde72871a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (69577e4): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

meanrangecount
Regressions ❌
(primary)
15.8%[2.1%, 43.6%]19
Regressions ❌
(secondary)
13.1%[0.3%, 120.7%]19
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)15.8%[2.1%, 43.6%]19

Max RSS (memory usage)

Results (primary 5.4%, secondary 4.2%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
5.4%[1.5%, 14.9%]16
Regressions ❌
(secondary)
4.2%[1.4%, 8.7%]8
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)5.4%[1.5%, 14.9%]16

Cycles

Results (primary 20.6%, secondary 15.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
20.6%[2.9%, 55.9%]19
Regressions ❌
(secondary)
15.8%[2.2%, 102.7%]14
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)20.6%[2.9%, 55.9%]19

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 497.93s -> 498.488s (0.11%)
Artifact size: 397.14 MiB -> 397.08 MiB (-0.01%)

@rustbotrustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels May 9, 2026
@fmease

fmease commented May 10, 2026

Copy link
Copy Markdown
MemberAuthor

This one is a real perf improvement over baseline PR #156348 (of course overall, this feature is extremely costly). See for example:

BenchmarkProfileScenarioBackendTarget% ChangeSignificance ThresholdSignificance Factor
nalgebra-0.33.0docfullllvmx64-5.69%0.20%28.44x
diesel-2.2.10docfullllvmx64-3.13%0.20%15.65x
stm32f4-0.15.1docfullllvmx64-0.49%0.20%2.43x
typenum-1.18.0docfullllvmx64-0.41%0.20%2.03x
hyper-1.6.0docfullllvmx64-0.34%0.20%1.71x
cranelift-codegen-0.119.0docfullllvmx64-0.34%0.20%1.68x

nalgebra-0.33.0:

Query/FunctionTime (%)Time (s)Time deltaExecutionsExecutions deltaHitsHits delta
Totals109.93%2.198-0.125 (-5.4%)1614385-5363 (-0.3%)17019283-1401012 (-7.6%)
typeck_root16.23%0.357-0.092 (-20.5%)1764-894 (-33.6%)397-6754 (-94.4%)
........................

fmease added 3 commits May 10, 2026 20:59
…e it always is
`rustc_resolve` doesn't resolve type-relative paths since that's the job
of HIR ty lowering and HIR typeck. `segment.res` comes from
`rustc_resolve` and is thus always `Res::Err`.
So just try to obtain the `TypeckResults` immediately since they contain
the actual resolution as deduced by HIR typeck.
@fmease
fmeaseforce-pushed the rustdoc-ltd-lazy-cached-typck branch from 78960ac to fc18b43CompareMay 10, 2026 19:04
@fmease

Copy link
Copy Markdown
MemberAuthor

NEW: We no longer special-case ExprKind::Call meaning we no longer needlessly obtain the type-dependent definition of callees that are Resolved paths which allows us to skip typecking the body entirely if the body doesn't contain any type-relative paths.

@fmease

Copy link
Copy Markdown
MemberAuthor

@bors try parent=last @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors

This comment has been minimized.

@fmease

Copy link
Copy Markdown
MemberAuthor

@bors try parent=last @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 11, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request May 11, 2026
[perf-only] rustdoc: Unconditionally enable `--generate-link-to-definition` and lazily typeck nested bodies with a cache
@rust-bors

rust-borsBot commented May 11, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 78d15de (78d15de5525370011388c8f63847e873c4de14ed, parent: fb0a5a5a9c892b351f34263d6d84da9dde72871a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (78d15de): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

meanrangecount
Regressions ❌
(primary)
14.9%[1.7%, 41.9%]19
Regressions ❌
(secondary)
11.8%[0.2%, 120.0%]18
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)14.9%[1.7%, 41.9%]19

Max RSS (memory usage)

Results (primary 5.3%, secondary 4.8%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
5.3%[1.2%, 15.4%]16
Regressions ❌
(secondary)
4.8%[1.4%, 9.0%]4
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)5.3%[1.2%, 15.4%]16

Cycles

Results (primary 18.7%, secondary 16.6%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
18.7%[2.3%, 52.6%]20
Regressions ❌
(secondary)
16.6%[2.1%, 101.2%]11
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)18.7%[2.3%, 52.6%]20

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 497.93s -> 500.833s (0.58%)
Artifact size: 397.14 MiB -> 397.12 MiB (-0.00%)

@rustbotrustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 11, 2026
@fmease

fmease commented May 11, 2026

Copy link
Copy Markdown
MemberAuthor

Compared to baseline:

Primary:

BenchmarkProfileScenarioBackendTarget% ChangeSignificance ThresholdSignificance Factor
nalgebra-0.33.0docfullllvmx64-5.82%0.20%29.09x
diesel-2.2.10docfullllvmx64-3.41%0.20%17.05x
image-0.25.6docfullllvmx64-2.03%0.20%10.16x
regex-automata-0.4.8docfullllvmx64-1.94%0.20%9.71x
cargo-0.87.1docfullllvmx64-1.64%0.20%8.21x
clap_derive-4.5.32docfullllvmx64-1.63%0.20%8.14x
cranelift-codegen-0.119.0docfullllvmx64-1.48%0.20%7.41x
syn-2.0.101docfullllvmx64-1.07%0.20%5.35x
ripgrep-14.1.1docfullllvmx64-0.96%0.20%4.78x
stm32f4-0.15.1docfullllvmx64-0.80%0.20%4.01x
serde-1.0.219docfullllvmx64-0.67%0.20%3.33x
hyper-1.6.0docfullllvmx64-0.66%0.20%3.30x
eza-0.21.2docfullllvmx64-0.55%0.20%2.74x
unicode-normalization-0.1.24docfullllvmx64-0.49%0.20%2.45x
serde_derive-1.0.219docfullllvmx64-0.45%0.20%2.26x
typenum-1.18.0docfullllvmx64-0.42%0.20%2.08x
bitmaps-3.2.1docfullllvmx64-0.32%0.20%1.61x

Secondary:

BenchmarkProfileScenarioBackendTarget% ChangeSignificance ThresholdSignificance Factor
deep-vectordocfullllvmx64-23.96%0.20%119.78x
large-workspacedocfullllvmx64-2.16%0.20%10.81x
deeply-nested-multidocfullllvmx64-1.35%0.20%6.75x
serde-1.0.219-threads4docfullllvmx64-0.67%0.20%3.33x
wg-grammardocfullllvmx64-0.32%0.20%1.62x
tt-muncheroptfullllvmx64-0.31%0.20%1.56x

nalgebra-0.33.0:

Query/FunctionTime (%)Time (s)Time deltaExecutionsExecutions deltaHitsHits delta
Totals109.57%2.185-0.138 (-5.9%)1614146-5602 (-0.3%)16983840-1436455 (-7.8%)
typeck_root15.75%0.344-0.105 (-23.4%)1704-954 (-35.9%)393-6758 (-94.5%)
........................

@fmease

Copy link
Copy Markdown
MemberAuthor

Hopefully final perf run...

@bors try parent=last @rust-timer queue

@rust-timer

This comment has been minimized.

@rustbotrustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 11, 2026
@rust-bors

This comment has been minimized.

rust-borsBot pushed a commit that referenced this pull request May 11, 2026
[perf-only] rustdoc: Unconditionally enable `--generate-link-to-definition` and lazily typeck nested bodies with a cache
@rust-bors

rust-borsBot commented May 11, 2026

Copy link
Copy Markdown
Contributor

☀️ Try build successful (CI)
Build commit: 1a5dfbb (1a5dfbb3f6a9ff1e5aec8eca78eadaa8c830014d, parent: fb0a5a5a9c892b351f34263d6d84da9dde72871a)

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (1a5dfbb): comparison URL.

Overall result: ❌ regressions - please read:

Benchmarking means the PR may be perf-sensitive. It's automatically marked not fit for rolling up. Overriding is possible but disadvised: it risks changing compiler perf.

Next, please: If you can, justify the regressions found in this try perf run in writing along with @rustbot label: +perf-regression-triaged. If not, fix the regressions and do another perf run. Neutral or positive results will clear the label automatically.

@bors rollup=never
@rustbot label: -S-waiting-on-perf +perf-regression

Instruction count

Our most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.

meanrangecount
Regressions ❌
(primary)
14.9%[1.7%, 42.0%]19
Regressions ❌
(secondary)
11.8%[0.2%, 120.0%]18
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)14.9%[1.7%, 42.0%]19

Max RSS (memory usage)

Results (primary 5.4%, secondary 4.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
5.4%[1.5%, 14.9%]15
Regressions ❌
(secondary)
4.1%[1.2%, 8.6%]5
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)5.4%[1.5%, 14.9%]15

Cycles

Results (primary 19.3%, secondary 18.1%)

A less reliable metric. May be of interest, but not used to determine the overall result above.

meanrangecount
Regressions ❌
(primary)
19.3%[2.0%, 52.2%]19
Regressions ❌
(secondary)
18.1%[2.0%, 101.5%]10
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
--0
All ❌✅ (primary)19.3%[2.0%, 52.2%]19

Binary size

This perf run didn't have relevant results for this metric.

Bootstrap: 497.93s -> 497.528s (-0.08%)
Artifact size: 397.14 MiB -> 397.14 MiB (0.00%)

@rustbotrustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label May 11, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 12, 2026
…laumeGomez
rustdoc: Correctness & perf improvements to link-to-definition
Rewrite the way we resolve type-dependent paths (incl. method calls) in `SpanMapVisitor`. Instead of trying to (re)find the enclosing body owner each time we encounter such a node, potentially calling `typeck_body` several times per body, keep track of the "active" `BodyId` in the visitor and cache the corresponding `TypeckResults`. The "active" `BodyId` is updated in `visit_nested_body` (add) and in `visit_item` (remove).
This fixes a class of ICEs where we tried to look up the definition of type-relative paths located in non-body items nested in bodies, in the overarching body which is never correct. rustdoc@main has a hack to fix this issue for paths specifically found in assoc types in impls.
Fixesrust-lang#147882. Fixesrust-lang#147057. Fixesrust-lang#155327. Fixesrust-lang#149089. Fixesrust-lang#150153.
Supersedes rust-lang#147911.
---
`--generate-link-to-definition` is not enabled by default, so we can't perf this as is. Instead, I'm benching them against PR rust-lang#156348 in PR rust-lang#156355 using the same parent commit for the try-builds. For context, LTD is *extremely* costly as the perf run for the baseline PR shows: rust-lang#156348 (comment).
"Absolute results": rust-lang#156355 (comment).
"Relative results": [https://perf.rust-lang.org/compare.html?...](https://perf.rust-lang.org/compare.html?start=68c2bff6cb08a87e59246064a6a9f37098e22c3f&end=78d15de5525370011388c8f63847e873c4de14ed&stat=instructions%3Au).
Excerpt of the relative results:
Primary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
nalgebra-0.33.0 | doc | full | llvm | x64 | -5.82% | 0.20% | 29.09x
diesel-2.2.10 | doc | full | llvm | x64 | -3.41% | 0.20% | 17.05x
image-0.25.6 | doc | full | llvm | x64 | -2.03% | 0.20% | 10.16x
regex-automata-0.4.8 | doc | full | llvm | x64 | -1.94% | 0.20% | 9.71x
cargo-0.87.1 | doc | full | llvm | x64 | -1.64% | 0.20% | 8.21x
clap_derive-4.5.32 | doc | full | llvm | x64 | -1.63% | 0.20% | 8.14x
cranelift-codegen-0.119.0 | doc | full | llvm | x64 | -1.48% | 0.20% | 7.41x
syn-2.0.101 | doc | full | llvm | x64 | -1.07% | 0.20% | 5.35x
ripgrep-14.1.1 | doc | full | llvm | x64 | -0.96% | 0.20% | 4.78x
stm32f4-0.15.1 | doc | full | llvm | x64 | -0.80% | 0.20% | 4.01x
serde-1.0.219 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
hyper-1.6.0 | doc | full | llvm | x64 | -0.66% | 0.20% | 3.30x
eza-0.21.2 | doc | full | llvm | x64 | -0.55% | 0.20% | 2.74x
unicode-normalization-0.1.24 | doc | full | llvm | x64 | -0.49% | 0.20% | 2.45x
serde_derive-1.0.219 | doc | full | llvm | x64 | -0.45% | 0.20% | 2.26x
typenum-1.18.0 | doc | full | llvm | x64 | -0.42% | 0.20% | 2.08x
bitmaps-3.2.1 | doc | full | llvm | x64 | -0.32% | 0.20% | 1.61x
Secondary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
deep-vector | doc | full | llvm | x64 | -23.96% | 0.20% | 119.78x
large-workspace | doc | full | llvm | x64 | -2.16% | 0.20% | 10.81x
deeply-nested-multi | doc | full | llvm | x64 | -1.35% | 0.20% | 6.75x
serde-1.0.219-threads4 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
wg-grammar | doc | full | llvm | x64 | -0.32% | 0.20% | 1.62x
tt-muncher | opt | full | llvm | x64 | -0.31% | 0.20% | 1.56x
nalgebra-0.33.0:
Query/Function | Time (%) | Time (s) | Time delta | Executions | Executions delta | Hits | Hits delta
---|---|---|---|---|---|---|---
Totals | 109.57% | 2.185 | -0.138 (-5.9%) | 1614146 | -5602 (-0.3%) | 16983840 | -1436455 (-7.8%)
typeck_root | 15.75% | 0.344 | -0.105 (-23.4%) | 1704 | -954 (-35.9%) | 393 | -6758 (-94.5%)
...|...|...|...|...|...|...|...
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 13, 2026
…laumeGomez
rustdoc: Correctness & perf improvements to link-to-definition
Rewrite the way we resolve type-dependent paths (incl. method calls) in `SpanMapVisitor`. Instead of trying to (re)find the enclosing body owner each time we encounter such a node, potentially calling `typeck_body` several times per body, keep track of the "active" `BodyId` in the visitor and cache the corresponding `TypeckResults`. The "active" `BodyId` is updated in `visit_nested_body` (add) and in `visit_item` (remove).
This fixes a class of ICEs where we tried to look up the definition of type-relative paths located in non-body items nested in bodies, in the overarching body which is never correct. rustdoc@main has a hack to fix this issue for paths specifically found in assoc types in impls.
Fixesrust-lang#147882. Fixesrust-lang#147057. Fixesrust-lang#155327. Fixesrust-lang#149089. Fixesrust-lang#150153. Fixesrust-lang#156418.
Supersedes rust-lang#147911.
---
`--generate-link-to-definition` is not enabled by default, so we can't perf this as is. Instead, I'm benching them against PR rust-lang#156348 in PR rust-lang#156355 using the same parent commit for the try-builds. For context, LTD is *extremely* costly as the perf run for the baseline PR shows: rust-lang#156348 (comment).
"Absolute results": rust-lang#156355 (comment).
"Relative results": [https://perf.rust-lang.org/compare.html?...](https://perf.rust-lang.org/compare.html?start=68c2bff6cb08a87e59246064a6a9f37098e22c3f&end=78d15de5525370011388c8f63847e873c4de14ed&stat=instructions%3Au).
Excerpt of the relative results:
Primary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
nalgebra-0.33.0 | doc | full | llvm | x64 | -5.82% | 0.20% | 29.09x
diesel-2.2.10 | doc | full | llvm | x64 | -3.41% | 0.20% | 17.05x
image-0.25.6 | doc | full | llvm | x64 | -2.03% | 0.20% | 10.16x
regex-automata-0.4.8 | doc | full | llvm | x64 | -1.94% | 0.20% | 9.71x
cargo-0.87.1 | doc | full | llvm | x64 | -1.64% | 0.20% | 8.21x
clap_derive-4.5.32 | doc | full | llvm | x64 | -1.63% | 0.20% | 8.14x
cranelift-codegen-0.119.0 | doc | full | llvm | x64 | -1.48% | 0.20% | 7.41x
syn-2.0.101 | doc | full | llvm | x64 | -1.07% | 0.20% | 5.35x
ripgrep-14.1.1 | doc | full | llvm | x64 | -0.96% | 0.20% | 4.78x
stm32f4-0.15.1 | doc | full | llvm | x64 | -0.80% | 0.20% | 4.01x
serde-1.0.219 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
hyper-1.6.0 | doc | full | llvm | x64 | -0.66% | 0.20% | 3.30x
eza-0.21.2 | doc | full | llvm | x64 | -0.55% | 0.20% | 2.74x
unicode-normalization-0.1.24 | doc | full | llvm | x64 | -0.49% | 0.20% | 2.45x
serde_derive-1.0.219 | doc | full | llvm | x64 | -0.45% | 0.20% | 2.26x
typenum-1.18.0 | doc | full | llvm | x64 | -0.42% | 0.20% | 2.08x
bitmaps-3.2.1 | doc | full | llvm | x64 | -0.32% | 0.20% | 1.61x
Secondary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
deep-vector | doc | full | llvm | x64 | -23.96% | 0.20% | 119.78x
large-workspace | doc | full | llvm | x64 | -2.16% | 0.20% | 10.81x
deeply-nested-multi | doc | full | llvm | x64 | -1.35% | 0.20% | 6.75x
serde-1.0.219-threads4 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
wg-grammar | doc | full | llvm | x64 | -0.32% | 0.20% | 1.62x
tt-muncher | opt | full | llvm | x64 | -0.31% | 0.20% | 1.56x
nalgebra-0.33.0:
Query/Function | Time (%) | Time (s) | Time delta | Executions | Executions delta | Hits | Hits delta
---|---|---|---|---|---|---|---
Totals | 109.57% | 2.185 | -0.138 (-5.9%) | 1614146 | -5602 (-0.3%) | 16983840 | -1436455 (-7.8%)
typeck_root | 15.75% | 0.344 | -0.105 (-23.4%) | 1704 | -954 (-35.9%) | 393 | -6758 (-94.5%)
...|...|...|...|...|...|...|...
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 13, 2026
…laumeGomez
rustdoc: Correctness & perf improvements to link-to-definition
Rewrite the way we resolve type-dependent paths (incl. method calls) in `SpanMapVisitor`. Instead of trying to (re)find the enclosing body owner each time we encounter such a node, potentially calling `typeck_body` several times per body, keep track of the "active" `BodyId` in the visitor and cache the corresponding `TypeckResults`. The "active" `BodyId` is updated in `visit_nested_body` (add) and in `visit_item` (remove).
This fixes a class of ICEs where we tried to look up the definition of type-relative paths located in non-body items nested in bodies, in the overarching body which is never correct. rustdoc@main has a hack to fix this issue for paths specifically found in assoc types in impls.
Fixesrust-lang#147882. Fixesrust-lang#147057. Fixesrust-lang#155327. Fixesrust-lang#149089. Fixesrust-lang#150153. Fixesrust-lang#156418.
Supersedes rust-lang#147911.
---
`--generate-link-to-definition` is not enabled by default, so we can't perf this as is. Instead, I'm benching them against PR rust-lang#156348 in PR rust-lang#156355 using the same parent commit for the try-builds. For context, LTD is *extremely* costly as the perf run for the baseline PR shows: rust-lang#156348 (comment).
"Absolute results": rust-lang#156355 (comment).
"Relative results": [https://perf.rust-lang.org/compare.html?...](https://perf.rust-lang.org/compare.html?start=68c2bff6cb08a87e59246064a6a9f37098e22c3f&end=78d15de5525370011388c8f63847e873c4de14ed&stat=instructions%3Au).
Excerpt of the relative results:
Primary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
nalgebra-0.33.0 | doc | full | llvm | x64 | -5.82% | 0.20% | 29.09x
diesel-2.2.10 | doc | full | llvm | x64 | -3.41% | 0.20% | 17.05x
image-0.25.6 | doc | full | llvm | x64 | -2.03% | 0.20% | 10.16x
regex-automata-0.4.8 | doc | full | llvm | x64 | -1.94% | 0.20% | 9.71x
cargo-0.87.1 | doc | full | llvm | x64 | -1.64% | 0.20% | 8.21x
clap_derive-4.5.32 | doc | full | llvm | x64 | -1.63% | 0.20% | 8.14x
cranelift-codegen-0.119.0 | doc | full | llvm | x64 | -1.48% | 0.20% | 7.41x
syn-2.0.101 | doc | full | llvm | x64 | -1.07% | 0.20% | 5.35x
ripgrep-14.1.1 | doc | full | llvm | x64 | -0.96% | 0.20% | 4.78x
stm32f4-0.15.1 | doc | full | llvm | x64 | -0.80% | 0.20% | 4.01x
serde-1.0.219 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
hyper-1.6.0 | doc | full | llvm | x64 | -0.66% | 0.20% | 3.30x
eza-0.21.2 | doc | full | llvm | x64 | -0.55% | 0.20% | 2.74x
unicode-normalization-0.1.24 | doc | full | llvm | x64 | -0.49% | 0.20% | 2.45x
serde_derive-1.0.219 | doc | full | llvm | x64 | -0.45% | 0.20% | 2.26x
typenum-1.18.0 | doc | full | llvm | x64 | -0.42% | 0.20% | 2.08x
bitmaps-3.2.1 | doc | full | llvm | x64 | -0.32% | 0.20% | 1.61x
Secondary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
deep-vector | doc | full | llvm | x64 | -23.96% | 0.20% | 119.78x
large-workspace | doc | full | llvm | x64 | -2.16% | 0.20% | 10.81x
deeply-nested-multi | doc | full | llvm | x64 | -1.35% | 0.20% | 6.75x
serde-1.0.219-threads4 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
wg-grammar | doc | full | llvm | x64 | -0.32% | 0.20% | 1.62x
tt-muncher | opt | full | llvm | x64 | -0.31% | 0.20% | 1.56x
nalgebra-0.33.0:
Query/Function | Time (%) | Time (s) | Time delta | Executions | Executions delta | Hits | Hits delta
---|---|---|---|---|---|---|---
Totals | 109.57% | 2.185 | -0.138 (-5.9%) | 1614146 | -5602 (-0.3%) | 16983840 | -1436455 (-7.8%)
typeck_root | 15.75% | 0.344 | -0.105 (-23.4%) | 1704 | -954 (-35.9%) | 393 | -6758 (-94.5%)
...|...|...|...|...|...|...|...
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request May 13, 2026
…laumeGomez
rustdoc: Correctness & perf improvements to link-to-definition
Rewrite the way we resolve type-dependent paths (incl. method calls) in `SpanMapVisitor`. Instead of trying to (re)find the enclosing body owner each time we encounter such a node, potentially calling `typeck_body` several times per body, keep track of the "active" `BodyId` in the visitor and cache the corresponding `TypeckResults`. The "active" `BodyId` is updated in `visit_nested_body` (add) and in `visit_item` (remove).
This fixes a class of ICEs where we tried to look up the definition of type-relative paths located in non-body items nested in bodies, in the overarching body which is never correct. rustdoc@main has a hack to fix this issue for paths specifically found in assoc types in impls.
Fixesrust-lang#147882. Fixesrust-lang#147057. Fixesrust-lang#155327. Fixesrust-lang#149089. Fixesrust-lang#150153. Fixesrust-lang#156418.
Supersedes rust-lang#147911.
---
`--generate-link-to-definition` is not enabled by default, so we can't perf this as is. Instead, I'm benching them against PR rust-lang#156348 in PR rust-lang#156355 using the same parent commit for the try-builds. For context, LTD is *extremely* costly as the perf run for the baseline PR shows: rust-lang#156348 (comment).
"Absolute results": rust-lang#156355 (comment).
"Relative results": [https://perf.rust-lang.org/compare.html?...](https://perf.rust-lang.org/compare.html?start=68c2bff6cb08a87e59246064a6a9f37098e22c3f&end=78d15de5525370011388c8f63847e873c4de14ed&stat=instructions%3Au).
Excerpt of the relative results:
Primary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
nalgebra-0.33.0 | doc | full | llvm | x64 | -5.82% | 0.20% | 29.09x
diesel-2.2.10 | doc | full | llvm | x64 | -3.41% | 0.20% | 17.05x
image-0.25.6 | doc | full | llvm | x64 | -2.03% | 0.20% | 10.16x
regex-automata-0.4.8 | doc | full | llvm | x64 | -1.94% | 0.20% | 9.71x
cargo-0.87.1 | doc | full | llvm | x64 | -1.64% | 0.20% | 8.21x
clap_derive-4.5.32 | doc | full | llvm | x64 | -1.63% | 0.20% | 8.14x
cranelift-codegen-0.119.0 | doc | full | llvm | x64 | -1.48% | 0.20% | 7.41x
syn-2.0.101 | doc | full | llvm | x64 | -1.07% | 0.20% | 5.35x
ripgrep-14.1.1 | doc | full | llvm | x64 | -0.96% | 0.20% | 4.78x
stm32f4-0.15.1 | doc | full | llvm | x64 | -0.80% | 0.20% | 4.01x
serde-1.0.219 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
hyper-1.6.0 | doc | full | llvm | x64 | -0.66% | 0.20% | 3.30x
eza-0.21.2 | doc | full | llvm | x64 | -0.55% | 0.20% | 2.74x
unicode-normalization-0.1.24 | doc | full | llvm | x64 | -0.49% | 0.20% | 2.45x
serde_derive-1.0.219 | doc | full | llvm | x64 | -0.45% | 0.20% | 2.26x
typenum-1.18.0 | doc | full | llvm | x64 | -0.42% | 0.20% | 2.08x
bitmaps-3.2.1 | doc | full | llvm | x64 | -0.32% | 0.20% | 1.61x
Secondary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
deep-vector | doc | full | llvm | x64 | -23.96% | 0.20% | 119.78x
large-workspace | doc | full | llvm | x64 | -2.16% | 0.20% | 10.81x
deeply-nested-multi | doc | full | llvm | x64 | -1.35% | 0.20% | 6.75x
serde-1.0.219-threads4 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
wg-grammar | doc | full | llvm | x64 | -0.32% | 0.20% | 1.62x
tt-muncher | opt | full | llvm | x64 | -0.31% | 0.20% | 1.56x
nalgebra-0.33.0:
Query/Function | Time (%) | Time (s) | Time delta | Executions | Executions delta | Hits | Hits delta
---|---|---|---|---|---|---|---
Totals | 109.57% | 2.185 | -0.138 (-5.9%) | 1614146 | -5602 (-0.3%) | 16983840 | -1436455 (-7.8%)
typeck_root | 15.75% | 0.344 | -0.105 (-23.4%) | 1704 | -954 (-35.9%) | 393 | -6758 (-94.5%)
...|...|...|...|...|...|...|...
rust-timer added a commit that referenced this pull request May 14, 2026
Rollup merge of #156413 - fmease:rustdoc-ltd-improvs, r=GuillaumeGomez
rustdoc: Correctness & perf improvements to link-to-definition
Rewrite the way we resolve type-dependent paths (incl. method calls) in `SpanMapVisitor`. Instead of trying to (re)find the enclosing body owner each time we encounter such a node, potentially calling `typeck_body` several times per body, keep track of the "active" `BodyId` in the visitor and cache the corresponding `TypeckResults`. The "active" `BodyId` is updated in `visit_nested_body` (add) and in `visit_item` (remove).
This fixes a class of ICEs where we tried to look up the definition of type-relative paths located in non-body items nested in bodies, in the overarching body which is never correct. rustdoc@main has a hack to fix this issue for paths specifically found in assoc types in impls.
Fixes#147882. Fixes#147057. Fixes#155327. Fixes#149089. Fixes#150153. Fixes#156418.
Supersedes #147911.
---
`--generate-link-to-definition` is not enabled by default, so we can't perf this as is. Instead, I'm benching them against PR #156348 in PR #156355 using the same parent commit for the try-builds. For context, LTD is *extremely* costly as the perf run for the baseline PR shows: #156348 (comment).
"Absolute results": #156355 (comment).
"Relative results": [https://perf.rust-lang.org/compare.html?...](https://perf.rust-lang.org/compare.html?start=68c2bff6cb08a87e59246064a6a9f37098e22c3f&end=78d15de5525370011388c8f63847e873c4de14ed&stat=instructions%3Au).
Excerpt of the relative results:
Primary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
nalgebra-0.33.0 | doc | full | llvm | x64 | -5.82% | 0.20% | 29.09x
diesel-2.2.10 | doc | full | llvm | x64 | -3.41% | 0.20% | 17.05x
image-0.25.6 | doc | full | llvm | x64 | -2.03% | 0.20% | 10.16x
regex-automata-0.4.8 | doc | full | llvm | x64 | -1.94% | 0.20% | 9.71x
cargo-0.87.1 | doc | full | llvm | x64 | -1.64% | 0.20% | 8.21x
clap_derive-4.5.32 | doc | full | llvm | x64 | -1.63% | 0.20% | 8.14x
cranelift-codegen-0.119.0 | doc | full | llvm | x64 | -1.48% | 0.20% | 7.41x
syn-2.0.101 | doc | full | llvm | x64 | -1.07% | 0.20% | 5.35x
ripgrep-14.1.1 | doc | full | llvm | x64 | -0.96% | 0.20% | 4.78x
stm32f4-0.15.1 | doc | full | llvm | x64 | -0.80% | 0.20% | 4.01x
serde-1.0.219 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
hyper-1.6.0 | doc | full | llvm | x64 | -0.66% | 0.20% | 3.30x
eza-0.21.2 | doc | full | llvm | x64 | -0.55% | 0.20% | 2.74x
unicode-normalization-0.1.24 | doc | full | llvm | x64 | -0.49% | 0.20% | 2.45x
serde_derive-1.0.219 | doc | full | llvm | x64 | -0.45% | 0.20% | 2.26x
typenum-1.18.0 | doc | full | llvm | x64 | -0.42% | 0.20% | 2.08x
bitmaps-3.2.1 | doc | full | llvm | x64 | -0.32% | 0.20% | 1.61x
Secondary:
Benchmark | Profile | Scenario | Backend | Target | % Change | Significance Threshold | Significance Factor
---|---|---|---|---|---|---|---
deep-vector | doc | full | llvm | x64 | -23.96% | 0.20% | 119.78x
large-workspace | doc | full | llvm | x64 | -2.16% | 0.20% | 10.81x
deeply-nested-multi | doc | full | llvm | x64 | -1.35% | 0.20% | 6.75x
serde-1.0.219-threads4 | doc | full | llvm | x64 | -0.67% | 0.20% | 3.33x
wg-grammar | doc | full | llvm | x64 | -0.32% | 0.20% | 1.62x
tt-muncher | opt | full | llvm | x64 | -0.31% | 0.20% | 1.56x
nalgebra-0.33.0:
Query/Function | Time (%) | Time (s) | Time delta | Executions | Executions delta | Hits | Hits delta
---|---|---|---|---|---|---|---
Totals | 109.57% | 2.185 | -0.138 (-5.9%) | 1614146 | -5602 (-0.3%) | 16983840 | -1436455 (-7.8%)
typeck_root | 15.75% | 0.344 | -0.105 (-23.4%) | 1704 | -954 (-35.9%) | 393 | -6758 (-94.5%)
...|...|...|...|...|...|...|...
@rust-bors

rust-borsBot commented May 14, 2026

Copy link
Copy Markdown
Contributor

☔ The latest upstream changes (presumably #156559) made this pull request unmergeable. Please resolve the merge conflicts.

@fmeasefmease closed this May 14, 2026
@fmease
fmease deleted the rustdoc-ltd-lazy-cached-typck branch May 14, 2026 06:34
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regressionPerformance regression.rla-silencedSilences rust-log-analyzer postings to the PR it's added on.S-experimentalStatus: Ongoing experiment that does not require reviewing and won't be merged in its current state.T-rustdocRelevant to the rustdoc team, which will review and decide on the PR/issue.T-rustdoc-frontendRelevant to the rustdoc-frontend team, which will review and decide on the web UI/UX output.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants

@fmease@rust-timer@rustbot