Skip to content

fix: Check the fallback map before queueing child in visible_parent_map breadth-first search - #160464

Merged
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zalanlevai:fix-visible-parent-map-fallback-entry-check
Aug 6, 2026
Merged

fix: Check the fallback map before queueing child in visible_parent_map breadth-first search#160464
rust-bors[bot] merged 1 commit into
rust-lang:mainfrom
zalanlevai:fix-visible-parent-map-fallback-entry-check

Conversation

@zalanlevai

@zalanlevai zalanlevai commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

View all comments

The fix in #159881 extended the visible_parent_map breadth-first search (BFS) to include items nested within "fallback" items, such as #[doc(hidden)] modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the libc performance regression described in #160439. (Fixes #160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. labels Aug 3, 2026
@rustbot

rustbot commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

r? @nnethercote

rustbot has assigned @nnethercote.
They will have a look at your PR within the next two weeks and either review your PR or reassign to another reviewer.

Use r? to explicitly pick a reviewer

Why was this reviewer chosen?

The reviewer was selected based on:

  • Owners of files modified in this PR: compiler
  • compiler expanded to 75 candidates
  • Random selection from 19 candidates

@zalanlevai zalanlevai changed the title fix: Check the fallback map before queueing child in visible_parent_map breadth-first-search fix: Check the fallback map before queueing child in visible_parent_map breadth-first search Aug 3, 2026
@zalanlevai

Copy link
Copy Markdown
Contributor Author

@rustbot label +perf-regression

@rustbot rustbot added the perf-regression Performance regression. label Aug 3, 2026
@zalanlevai

zalanlevai commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Actually, after looking at PRs labeled perf-regression, I think I used the label incorrectly as this PR fixes a performance regression, rather than introducing one.

@rustbot label -perf-regression

@rustbot rustbot removed the perf-regression Performance regression. label Aug 3, 2026
@tgross35

tgross35 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

That makes me think, maybe we could have a perf job that runs rustdoc on libc or any other larger crate? That would have caught this.

Cc @Kobzol

@zalanlevai

Copy link
Copy Markdown
Contributor Author

Huh, those CI failures on x86_64-gnu-gcc seem strange to me. All seven test failures are caused by the following unexpected warning on stderr:

libgccjit.so: warning: : ‘retain’ attribute ignored [-Wattributes]

Is my reading correct that the CI failure seems unrelated to this change and could be caused by something else?

@tgross35

tgross35 commented Aug 3, 2026

Copy link
Copy Markdown
Contributor

Looks like that job may be having some issues #t-infra > Tree ops @ 💬

@rust-log-analyzer

This comment has been minimized.

@Kobzol

Kobzol commented Aug 4, 2026

Copy link
Copy Markdown
Member

That makes me think, maybe we could have a perf job that runs rustdoc on libc or any other larger crate? That would have caught this.

Cc @Kobzol

We do actually run rustdoc on libc on every merge :) https://perf.rust-lang.org/compare.html?debug=false&check=false&opt=false&nonRelevant=true

@lqd lqd mentioned this pull request Aug 4, 2026
@tgross35

tgross35 commented Aug 4, 2026

Copy link
Copy Markdown
Contributor

Oh I was wondering why it didn't show up in https://perf.rust-lang.org/compare.html?start=b04d3c8c22822b7f10dab5a563b4e2afff1861c1&end=28c66af27578a28bc8cad1c5957be4b1e2e7fb8b&stat=instructions%3Au&nonRelevant=true&opt=false&debug=false&check=false&doc-json=false. But testing again locally, it looks like libc is actually fine but ctest in the same repo was hitting the crash.

@zalanlevai if you have a build locally, cargo doc -p ctest --no-deps in https://github.com/rust-lang/libc is how I'm able to reproduce the issue

@zalanlevai

Copy link
Copy Markdown
Contributor Author

Thank you @tgross35 for the reproducer! I can confirm that running cargo doc -p ctest --no-deps on rust-lang/libc locally runs perfectly fine with this fix applied (and that I can reproduce the hang locally if I remove my changes).

@zalanlevai

Copy link
Copy Markdown
Contributor Author

Should I force CI checks to re-run on this PR, now that the x86_64-gnu-gcc failures have been resolved?

@Kobzol

Kobzol commented Aug 4, 2026

Copy link
Copy Markdown
Member

Yeah, you can just repush the latest commit.

@zalanlevai
zalanlevai force-pushed the fix-visible-parent-map-fallback-entry-check branch from 464edf2 to 45cd627 Compare August 4, 2026 10:04
@rustbot

rustbot commented Aug 4, 2026

Copy link
Copy Markdown
Collaborator

This PR was rebased onto a different main commit. Here's a range-diff highlighting what actually changed.

Rebasing is a normal part of keeping PRs up to date, so no action is needed—this note is just to help reviewers.

@nnethercote

Copy link
Copy Markdown
Contributor

I'm going to pass this on to the reviewer of #159881:

r? @fee1-dead

@rustbot rustbot assigned fee1-dead and unassigned nnethercote Aug 5, 2026

@oli-obk oli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

r=me with the sorting avoided

View changes since this review

Comment thread compiler/rustc_metadata/src/rmeta/decoder/cstore_impl.rs Outdated
@rustbot rustbot added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 5, 2026
@rustbot

rustbot commented Aug 5, 2026

Copy link
Copy Markdown
Collaborator

Reminder, once the PR becomes ready for a review, use @rustbot ready.

@oli-obk oli-obk self-assigned this Aug 5, 2026
@zalanlevai
zalanlevai force-pushed the fix-visible-parent-map-fallback-entry-check branch from 45cd627 to 640032d Compare August 5, 2026 16:42
@zalanlevai

Copy link
Copy Markdown
Contributor Author

I have made the change we discussed. I also found a way to test the behaviour through path printing in diagnostics. Just like with regular entries, we expect to store the topmost fallback entry in the BFS to produce the shortest visible paths. This condition was failed for fallback items before this change. The added regression test checks that we do not override fallback entries with later ones by ensuring that we use the shortest available fallback path.

@rustbot ready

@rustbot rustbot added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Aug 5, 2026

@oli-obk oli-obk left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

@rust-bors

rust-bors Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

📌 Commit 640032d has been approved by oli-obk

It is now in the queue for this repository.

@rust-bors rust-bors Bot added S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Aug 6, 2026
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…fallback-entry-check, r=oli-obk

fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search

The fix in rust-lang#159881 extended the `visible_parent_map` breadth-first search (BFS) to include items nested within "fallback" items, such as `#[doc(hidden)]` modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the `libc` performance regression described in rust-lang#160439. (Fixes rust-lang#160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…fallback-entry-check, r=oli-obk

fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search

The fix in rust-lang#159881 extended the `visible_parent_map` breadth-first search (BFS) to include items nested within "fallback" items, such as `#[doc(hidden)]` modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the `libc` performance regression described in rust-lang#160439. (Fixes rust-lang#160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…fallback-entry-check, r=oli-obk

fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search

The fix in rust-lang#159881 extended the `visible_parent_map` breadth-first search (BFS) to include items nested within "fallback" items, such as `#[doc(hidden)]` modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the `libc` performance regression described in rust-lang#160439. (Fixes rust-lang#160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.
JonathanBrouwer added a commit to JonathanBrouwer/rust that referenced this pull request Aug 6, 2026
…fallback-entry-check, r=oli-obk

fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search

The fix in rust-lang#159881 extended the `visible_parent_map` breadth-first search (BFS) to include items nested within "fallback" items, such as `#[doc(hidden)]` modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the `libc` performance regression described in rust-lang#160439. (Fixes rust-lang#160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.
rust-bors Bot pushed a commit that referenced this pull request Aug 6, 2026
…uwer

Rollup of 17 pull requests

Successful merges:

 - #159530 (Cap socket send length to c_int::MAX on Apple targets)
 - #159506 (Allow associated const equality constraints with GCA)
 - #160006 (Account for desugaring in method call move errors)
 - #160415 (Split `aarch64-apple{,-macos-26}` => `aarch64-apple{,-macos-26}-{1,2}` jobs)
 - #160464 (fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search)
 - #160555 (Split `apply_primary_terminator_effect`)
 - #160592 (Suggest if-let chain continuation on unclosed delimiter)
 - #160600 (Avoid the std DLL copy alongside rustc)
 - #160156 (check_consts: exhaustively match on CastKind)
 - #160211 (Rename `#[unroll]` => `#[rustc_unroll]` to mitigate nameres ambiguity)
 - #160304 (Add tests for fixed new solver issues)
 - #160398 (rustc_abi: Add `LayoutData::is_variant_uninhabited` method)
 - #160546 (Update error message in documentation comments)
 - #160568 (Use `VisitorResult` helper macros)
 - #160571 (Add regression test for array type recovery in generic arguments)
 - #160588 (add a test showing polonius alpha is not a subset of datalog polonius)
 - #160617 (Add a suggestion to MissingUnsafeOnExtern diagnostic)
@rust-bors
rust-bors Bot merged commit c5549dd into rust-lang:main Aug 6, 2026
13 checks passed
@rustbot rustbot added this to the 1.99.0 milestone Aug 6, 2026
rust-timer added a commit that referenced this pull request Aug 6, 2026
Rollup merge of #160464 - zalanlevai:fix-visible-parent-map-fallback-entry-check, r=oli-obk

fix: Check the fallback map before queueing child in `visible_parent_map` breadth-first search

The fix in #159881 extended the `visible_parent_map` breadth-first search (BFS) to include items nested within "fallback" items, such as `#[doc(hidden)]` modules and re-exports. However, the fix resulted in fallback entries not being checked before enqueueing new items into the BFS, resulting in fallback items being explored in the BFS multiple times, once for each fallback parent, up until a non-fallback visible parent is found instead, if any.

This PR adds a check before new fallback items are recorded and the BFS queue is extended that ensures that the item has not already been searched through a fallback parent item.

Fixes the `libc` performance regression described in #160439. (Fixes #160439.)

Unfortunately, I could not think of a way to write a test case that covers the regression that this PR fixes, as it would require a massive crate with a very large number of "fallback" parents, and the test would be performance-based.
@JonathanBrouwer

Copy link
Copy Markdown
Contributor

@rust-timer build e577f4b

@rust-timer

This comment has been minimized.

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (e577f4b): comparison URL.

Overall result: ❌✅ regressions and improvements - 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 rustc-perf
@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.

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
0.4% [0.2%, 0.5%] 7
Improvements ✅
(primary)
-0.4% [-0.4%, -0.4%] 1
Improvements ✅
(secondary)
-0.4% [-0.5%, -0.2%] 7
All ❌✅ (primary) -0.4% [-0.4%, -0.4%] 1

Max RSS (memory usage)

Results (primary -6.6%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
-6.6% [-6.6%, -6.6%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -6.6% [-6.6%, -6.6%] 1

Cycles

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

Binary size

Results (secondary -0.0%)

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

mean range count
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
- - 0
Improvements ✅
(primary)
- - 0
Improvements ✅
(secondary)
-0.0% [-0.0%, -0.0%] 1
All ❌✅ (primary) - - 0

Bootstrap: 458.35s -> 458.321s (-0.01%)
Artifact size: 398.64 MiB -> 398.62 MiB (-0.01%)

@rustbot rustbot added the perf-regression Performance regression. label Aug 7, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

cargo doc freezes on libc with nightly-2026-08-03

10 participants