Skip to content
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

Querify FnAbi::of_{fn_ptr,instance} as fn_abi_of_{fn_ptr,instance}. #88575

Merged
merged 10 commits into from
Sep 20, 2021

Conversation

eddyb
Copy link
Member

@eddyb eddyb commented Sep 1, 2021

Note: opening this PR as draft because it's based on #88499

This more or less replicates the LayoutOf::layout_of setup from #88499, to replace FnAbi::of_{fn_ptr,instance} with FnAbiOf::fn_abi_of_{fn_ptr,instance}, and also route them through queries (which layout_of has used for a while).

The two changes at the use sites (other than the names) are:

  • return type is now wrapped in &'tcx
    • the value is interned, which may affect performance
  • the extra_args list is now an interned &'tcx ty::List<Ty<'tcx>>
    • should be cheap (it's empty for anything other than C variadics)

Theoretically, a FnAbiOfHelpers implementer could choose to keep the Result<...> instead of eagerly erroring, but the only existing users of these APIs are codegen backends, so they don't (want to) take advantage of this.
At least miri could make use of this, since it prefers propagating errors (it "just" doesn't use FnAbi yet - cc @RalfJung).

The way this is done is probably less efficient than what is possible, because the queries handle the correctness-oriented API (i.e. the split into fn pointers vs instances), whereas a lower-level query could end up with more reuse between different instances with identical signatures.

r? @nagisa cc @oli-obk @bjorn3

@rust-highfive
Copy link
Collaborator

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

Some changes occured to rustc_codegen_cranelift

cc @bjorn3

Some changes occurred in src/tools/clippy.

cc @rust-lang/clippy

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Sep 1, 2021
@eddyb eddyb marked this pull request as draft September 1, 2021 23:16
@eddyb
Copy link
Member Author

eddyb commented Sep 1, 2021

Thanks to #88499 (comment) (i.e. #88499 being perf-neutral), we should be able to get useful data despite this being based on #88499:

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 1, 2021
@bors
Copy link
Contributor

bors commented Sep 1, 2021

⌛ Trying commit c4b36be083fe7fcc74e824b1e15368094d58fbf8 with merge eb6a18b59b113d9f9fde80bfc8c1e43dca27c954...

@bors
Copy link
Contributor

bors commented Sep 2, 2021

☀️ Try build successful - checks-actions
Build commit: eb6a18b59b113d9f9fde80bfc8c1e43dca27c954 (eb6a18b59b113d9f9fde80bfc8c1e43dca27c954)

@rust-timer
Copy link
Collaborator

Queued eb6a18b59b113d9f9fde80bfc8c1e43dca27c954 with parent 50171c3, future comparison URL.

@RalfJung
Copy link
Member

RalfJung commented Sep 2, 2021

At least miri could make use of this, since it prefers propagating errors (it "just" doesn't use FnAbi yet - cc @RalfJung).

Yeah, it's on my list...
For LayoutOf, I think we have to properly propagate errors or some CTFE or pattern matching code will end up ICEing. Not sure if the same concern applies here.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (eb6a18b59b113d9f9fde80bfc8c1e43dca27c954): comparison url.

Summary: This change led to moderate relevant mixed results 🤷 in compiler performance.

  • Moderate improvement in instruction counts (up to -0.8% on full builds of regression-31157)
  • Moderate regression in instruction counts (up to 1.8% on full builds of cranelift-codegen)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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 led to changes in compiler perf.

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 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-review -S-waiting-on-perf +perf-regression

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Sep 2, 2021
@bjorn3
Copy link
Member

bjorn3 commented Sep 2, 2021

Unfortunately this is a clear perf regression.

@eddyb

This comment has been minimized.

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 2, 2021
@bors

This comment has been minimized.

@bors

This comment has been minimized.

@rust-timer

This comment has been minimized.

@rust-timer

This comment has been minimized.

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 2, 2021
@eddyb

This comment has been minimized.

@rust-timer

This comment has been minimized.

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Sep 2, 2021
@bors

This comment has been minimized.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 18, 2021

Yea, imo we can merge this if we have an issue for the incremental-unchanged regression that somewhat collects the information from this discussion

@wesleywiser
Copy link
Member

+1, seems ok to merge to me.

@nagisa
Copy link
Member

nagisa commented Sep 19, 2021

@bors r+ rollup=never

@bors
Copy link
Contributor

bors commented Sep 19, 2021

📌 Commit 8c918d7 has been approved by nagisa

@bors bors 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 Sep 19, 2021
@bors
Copy link
Contributor

bors commented Sep 19, 2021

⌛ Testing commit 8c918d7 with merge 9119882...

@bors
Copy link
Contributor

bors commented Sep 20, 2021

☀️ Test successful - checks-actions
Approved by: nagisa
Pushing 9119882 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Sep 20, 2021
@bors bors merged commit 9119882 into rust-lang:master Sep 20, 2021
@rustbot rustbot added this to the 1.57.0 milestone Sep 20, 2021
@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9119882): comparison url.

Summary: This change led to moderate relevant mixed results 🤷 in compiler performance.

  • Moderate improvement in instruction counts (up to -1.0% on full builds of regression-31157)
  • Moderate regression in instruction counts (up to 1.4% on incr-unchanged builds of regression-31157)

If you disagree with this performance assessment, please file an issue in rust-lang/rustc-perf.

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

@eddyb eddyb deleted the fn-abi-queries branch September 20, 2021 10:28
@pnkfelix
Copy link
Member

Visited for weekly performance triage. Results do indeed seem moderately mixed.

@eddyb
Copy link
Member Author

eddyb commented Sep 22, 2021

@pnkfelix It's a bit more subtle than that (only incr-{unchanged,patched} regressed), and it got discussed before landing (in fact I personally wasn't sure this could land any time soon), see #88575 (comment).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. perf-regression Performance regression. S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.
Projects
None yet
Development

Successfully merging this pull request may close these issues.