Skip to content

Remove TypeckResults from InferCtxt - #101632

Merged
bors merged 4 commits into
rust-lang:masterfrom
camsteffen:refactor-infer-err
Oct 7, 2022
Merged

Remove TypeckResults from InferCtxt#101632
bors merged 4 commits into
rust-lang:masterfrom
camsteffen:refactor-infer-err

Conversation

@camsteffen

@camsteffencamsteffen commented Sep 9, 2022

Copy link
Copy Markdown
Contributor

InferCtxt currently has in_progress_typeck_results which is only used for some diagnostics during typeck. It adds a lifetime which propagates through a lot of code. This PR moves that field into a new helper struct TypeErrCtxt.

@rustbotrustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Sep 9, 2022
@rust-highfive

Copy link
Copy Markdown
Contributor

r? @oli-obk

(rust-highfive has picked a reviewer for you, use r? to override)

@rustbot

Copy link
Copy Markdown
Collaborator

Some changes occurred in src/tools/clippy

cc @rust-lang/clippy

Some changes occurred in const_evaluatable.rs

cc @lcnr

Some changes occurred in need_type_info.rs

cc @lcnr

@rust-highfiverust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 9, 2022
@bors

bors commented Sep 11, 2022

Copy link
Copy Markdown
Collaborator

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

Comment threadcompiler/rustc_infer/src/infer/error_reporting/mod.rs Outdated
Comment threadcompiler/rustc_infer/src/infer/error_reporting/mod.rs Outdated
Comment threadcompiler/rustc_typeck/src/check/inherited.rs Outdated

@lcnrlcnr 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.

really happy about this PR as it is something i've wanted to do myself for quite a while ❤️

some nits and further suggestions, but this looks pretty good already

Comment threadcompiler/rustc_infer/src/infer/mod.rs Outdated
Comment threadcompiler/rustc_infer/src/infer/mod.rs Outdated
Comment threadcompiler/rustc_mir_build/src/thir/pattern/const_to_pat.rs Outdated
Comment threadcompiler/rustc_infer/src/infer/combine.rs Outdated
@lcnr

lcnr commented Sep 12, 2022

Copy link
Copy Markdown
Contributor

r? @lcnr

@rust-highfiverust-highfive assigned lcnr and unassigned oli-obkSep 12, 2022
@lcnrlcnr 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 Sep 12, 2022
@camsteffen
camsteffenforce-pushed the refactor-infer-err branch 2 times, most recently from 4c43c71 to ce7f171CompareSeptember 20, 2022 13:42
@camsteffen

Copy link
Copy Markdown
ContributorAuthor

I don't know where to start with the failing rustdoc tests 😤

@rust-log-analyzer

This comment has been minimized.

@bors

bors commented Sep 20, 2022

Copy link
Copy Markdown
Collaborator

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

@lcnr

lcnr commented Sep 21, 2022

Copy link
Copy Markdown
Contributor

🤔 i also can't tell why rustdoc is failing 😅 maybe look at the actually generated docs for the smallest failing test to check whether there are any user-visible changes? 🤔

@camsteffen

camsteffen commented Sep 29, 2022

Copy link
Copy Markdown
ContributorAuthor

Looks like a bit of waiting and doing nothing made the problem go away! nope

@camsteffen

Copy link
Copy Markdown
ContributorAuthor

@rustbot ready

@rustbotrustbot 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 Sep 29, 2022
@rust-log-analyzer

This comment has been minimized.

Comment threadsrc/librustdoc/clean/blanket_impl.rs Outdated
Comment threadcompiler/rustc_hir_analysis/src/check/fn_ctxt/mod.rs Outdated

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.

should these be on TypeErrCtxt instead?

Copy link
Copy Markdown
ContributorAuthor

Choose a reason for hiding this comment

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

Maybe? I was being conservative, only moving stuff to TypeErrCtxt if it needs TypeckResults.

Comment threadsrc/tools/clippy/clippy_lints/src/future_not_send.rs Outdated
@lcnr

lcnr commented Oct 3, 2022

Copy link
Copy Markdown
Contributor

small nits which we can fix in a followup pr

prone to merge conflicts:
@bors r+ p=5 rollup=never

@bors

bors commented Oct 3, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit d68bfb9012f16c29c52dea118439dc1c8d4354a5 has been approved by lcnr

It is now in the queue for this repository.

@borsbors added the S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. label Oct 7, 2022
@bors

bors commented Oct 7, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 283abbf with merge 43c22af...

@bors

bors commented Oct 7, 2022

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 43c22af to master...

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (43c22af): comparison URL.

Overall result: ❌✅ regressions and improvements - ACTION NEEDED

Next Steps: If you can justify the regressions found in this perf run, please indicate this with @rustbot label: +perf-regression-triaged along with sufficient written justification. If you cannot justify the regressions please open an issue or create a new PR that fixes the regressions, add a comment linking to the newly created issue or PR, and then add the perf-regression-triaged label to this PR.

@rustbot label: +perf-regression
cc @rust-lang/wg-compiler-performance

Instruction count

This is a highly reliable metric that was used to determine the overall result at the top of this comment.

mean1rangecount2
Regressions ❌
(primary)
0.7%[0.5%, 1.2%]13
Regressions ❌
(secondary)
4.3%[3.2%, 5.7%]6
Improvements ✅
(primary)
-0.3%[-0.6%, -0.2%]19
Improvements ✅
(secondary)
-0.6%[-1.6%, -0.2%]52
All ❌✅ (primary)0.1%[-0.6%, 1.2%]32

Max RSS (memory usage)

Results

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.

mean1rangecount2
Regressions ❌
(primary)
--0
Regressions ❌
(secondary)
3.5%[2.1%, 4.5%]4
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-2.6%[-2.9%, -2.3%]2
All ❌✅ (primary)--0

Cycles

Results

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.

mean1rangecount2
Regressions ❌
(primary)
2.4%[2.4%, 2.4%]1
Regressions ❌
(secondary)
3.4%[3.4%, 3.4%]1
Improvements ✅
(primary)
--0
Improvements ✅
(secondary)
-3.4%[-3.4%, -3.4%]1
All ❌✅ (primary)2.4%[2.4%, 2.4%]1

Footnotes

  1. the arithmetic mean of the percent change23

  2. number of relevant changes23

@rustbotrustbot added the perf-regression Performance regression. label Oct 7, 2022
@lcnr

lcnr commented Oct 10, 2022

Copy link
Copy Markdown
Contributor

oh wow, should have definitely run perf before approving this 😅

i guess this resulted in a lot of small inlining/optimization changes, might be worth to check out the flamegraph comparison of a few regressions to check if we can maybe fix them by putting #[inline] somewhere.

@rylev

Copy link
Copy Markdown
Member

@lcnr@camsteffen I ran callgrind diff on one of the benchmarks. Looks specialization_graph::Children::insert is getting called way more.

--------------------------------------------------------------------------------
Ir file:function
--------------------------------------------------------------------------------
94,311,966 ???:rustc_trait_selection::traits::coherence::overlapping_impls::<<rustc_middle::traits::specialization_graph::Children as rustc_trait_selection::traits::specialize::specialization_graph::ChildrenExt>::insert::{closure
-66,019,056 ???:<rustc_middle::traits::specialization_graph::Children as rustc_trait_selection::traits::specialize::specialization_graph::ChildrenExt>::insert
7,957,920 ???:__rust_probestack
-7,904,085 ???:<rustc_infer::infer::InferCtxtBuilder>::enter::<core::result::Result<alloc::vec::Vec<rustc_middle::ty::Predicate>, rustc_errors::ErrorGuaranteed>, rustc_trait_selection::traits::do_normalize_predicates::{closure
6,887,397 ???:rustc_trait_selection::traits::do_normalize_predicates
4,716,702 ???:<rustc_infer::infer::InferCtxt>::probe::<(), <rustc_trait_selection::traits::select::SelectionContext>::assemble_candidates_from_impls::{closure
-4,586,815 ???:<rustc_trait_selection::traits::select::SelectionContext>::match_impl
4,052,492 ???:<rustc_infer::infer::InferCtxtBuilder>::build
-3,625,123 /build/glibc-eX1tMB/glibc-2.31/string/../sysdeps/x86_64/multiarch/memmove-vec-unaligned-erms.S:__memcpy_avx_unaligned_erms

@camsteffen

Copy link
Copy Markdown
ContributorAuthor

Thanks @rylev. I think it might be traits::overlapping_impls that needs inline? I see that function in the callgrind diff, and the changes to that function might have made it not inlined anymore.

@rylev

Copy link
Copy Markdown
Member

@camsteffen the symbol is a bit hard to parse. It seems like it's not the function but possibly a closure inside of that function? Might require some experimentation.

@camsteffen

Copy link
Copy Markdown
ContributorAuthor

Probably this closure, and if overlapping_impls is inlined, then the closure would probably be inlined as well?

@camsteffen

Copy link
Copy Markdown
ContributorAuthor

bitmaps perf addressed in #102931. Looks like deeply-nested-multi could use another fix.

@nnethercote

Copy link
Copy Markdown
Contributor

deeply-nested-multi is less important, plus it has been noisy lately, so don't spend too much time on it.

@camsteffen

Copy link
Copy Markdown
ContributorAuthor

Thanks @nnethercote. I'll gladly ignore that.

bors added a commit to rust-lang-ci/rust that referenced this pull request Oct 16, 2022
… r=cjgillot
Make `overlapping_impls` not generic
Trying to win back perf from rust-lang#101632.
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

merged-by-borsThis PR was explicitly merged by bors.perf-regressionPerformance regression.S-waiting-on-borsStatus: Waiting on bors to run and complete tests. Bors will change the label on completion.T-compilerRelevant 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.

11 participants

@camsteffen@rust-highfive@rustbot@bors@lcnr@rust-log-analyzer@emilyalbini@rust-timer@rylev@nnethercote@oli-obk