Skip to content

Start moving wf checking away from HIR #142030

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 8 commits into
base: master
Choose a base branch
from

Conversation

oli-obk
Copy link
Contributor

@oli-obk oli-obk commented Jun 4, 2025

I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better.

I think I am reaching a blocker because we normally need to provide good spans to ObligationCause, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the ObligationCauseCode (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the ObligationCause entirely (leaving it to some variants of ObligationCauseCode to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks.

Especially b862d88 is interesting here, because I think it improves spans in all cases

@rustbot
Copy link
Collaborator

rustbot commented Jun 4, 2025

r? @SparrowLii

rustbot has assigned @SparrowLii.
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

@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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver) labels Jun 4, 2025
@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 4, 2025

@bors2 try @rust-timer queue

@rust-timer

This comment has been minimized.

@rust-bors
Copy link

rust-bors bot commented Jun 4, 2025

⌛ Trying commit e38ae45 with merge 2a676f2

To cancel the try build, run the command @bors2 try cancel.

rust-bors bot added a commit that referenced this pull request Jun 4, 2025
Start moving wf checking away from HIR

I'm trying to only access the HIR in the error path. My hope is that once we move significant portions of wfcheck off HIR that incremental will be able to cache wfcheck queries significantly better.

I think I am reaching a blocker because we normally need to provide good spans to `ObligationCause`, so that the trait solver can report good errors. In some cases I have been able to use bad spans and improve them depending on the `ObligationCauseCode` (by loading HIR in the case where we actually want to error). To scale that further we'll likely need to remove spans from the `ObligationCause` entirely (leaving it to some variants of `ObligationCauseCode` to have a span when they can't recompute the information later). Unsure this is the right approach, but we've already been using it. I will create an MCP about it, but that should not affect this PR, which is fairly limited in where it does those kind of tricks.

Especially b862d88 is interesting here, because I think it improves spans in all cases
@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Jun 4, 2025
@rust-bors
Copy link

rust-bors bot commented Jun 4, 2025

☀️ Try build successful (CI)
Build commit: 2a676f2 (2a676f231127fb1728da0a95c8deb1e1fb8bf0eb)

@rust-timer

This comment has been minimized.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (2a676f2): comparison URL.

Overall result: ❌✅ regressions and improvements - please read the text below

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf.

Next Steps: If you can justify the regressions found in this try perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please fix the regressions and do another perf run. If the next run shows neutral or positive results, the label will be automatically removed.

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

Instruction count

This is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.

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

Max RSS (memory usage)

Results (primary -3.0%, secondary 0.3%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

mean range count
Regressions ❌
(primary)
1.6% [1.5%, 1.7%] 2
Regressions ❌
(secondary)
2.0% [1.2%, 3.9%] 8
Improvements ✅
(primary)
-7.6% [-10.2%, -5.1%] 2
Improvements ✅
(secondary)
-2.3% [-2.9%, -1.8%] 5
All ❌✅ (primary) -3.0% [-10.2%, 1.7%] 4

Cycles

Results (primary 1.5%)

This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.

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

Binary size

This benchmark run did not return any relevant results for this metric.

Bootstrap: 749.479s -> 749.524s (0.01%)
Artifact size: 371.89 MiB -> 371.96 MiB (0.02%)

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 4, 2025
@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 5, 2025

Improvements are real, fewer dep graph edges to encode

Regressions are real, a mix of improvements and regressions across multiple queries. I'll do some local cache grinding to see what's going on

@oli-obk
Copy link
Contributor Author

oli-obk commented Jun 5, 2025

The regression is due to some extra query system things happening:

 2,302,905  ???:<rustc_middle::dep_graph::DepsType as rustc_query_system::dep_graph::Deps>::read_deps::<<rustc_query_system::dep_graph::graph::DepGraph<rustc_middle::dep_graph::DepsType>>::read_index::{closure
 1,917,000  ???:<hashbrown::raw::RawTable<(rustc_span::def_id::LocalDefId, ())>>::reserve_rehash::<hashbrown::map::make_hasher<rustc_span::def_id::LocalDefId, (), rustc_hash::FxBuildHasher>::{closure

Probably because I'm invoking more queries to avoid looking at HIR. I don't think my work pays off while we still check the HIR on so many items.

@bors
Copy link
Collaborator

bors commented Jun 6, 2025

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

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-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. WG-trait-system-refactor The Rustc Trait System Refactor Initiative (-Znext-solver)
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants