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

Make const_eval_select a real intrinsic #100759

Merged

Conversation

fee1-dead
Copy link
Member

@fee1-dead fee1-dead commented Aug 19, 2022

This fixes issues where track_caller functions do not have nice panic
messages anymore when there is a call to the function, and uses the
MIR system to replace the call instead of dispatching via lang items.

Fixes #100696.

@rustbot rustbot added T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue. labels Aug 19, 2022
@rust-highfive
Copy link
Collaborator

r? @davidtwco

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

@rustbot
Copy link
Collaborator

rustbot commented Aug 19, 2022

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

Hey! It looks like you've submitted a new PR for the library teams!

If this PR contains changes to any rust-lang/rust public library APIs then please comment with @rustbot label +T-libs-api -T-libs to tag it appropriately. If this PR contains changes to any unstable APIs please edit the PR description to add a link to the relevant API Change Proposal or create one if you haven't already. If you're unsure where your change falls no worries, just leave it as is and the reviewer will take a look and make a decision to forward on if necessary.

Examples of T-libs-api changes:

  • Stabilizing library features
  • Introducing insta-stable changes such as new implementations of existing stable traits on existing stable types
  • Introducing new or changing existing unstable library APIs (excluding permanently unstable features / features without a tracking issue)
  • Changing public documentation in ways that create new stability guarantees
  • Changing observable runtime behavior of library APIs

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Aug 19, 2022
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@fee1-dead fee1-dead force-pushed the const_eval_select_real_intrinsic branch 2 times, most recently from 79eca84 to 7aa26a1 Compare August 21, 2022 11:12
@RalfJung
Copy link
Member

Another possible implementation plan would be to exploit that we have separate MIR for CTFE and runtime, and implement the intrinsic via lowering to a regular function call some place in the MIR pipeline. That would make supporting track_caller trivial. It'd also share the code to do that between codegen and CTFE.

@fee1-dead
Copy link
Member Author

Another possible implementation plan would be to exploit that we have separate MIR for CTFE and runtime

Yes, but AFAIK there is no separate query for runtime-only MIR, right? Implementing it that way would require adding such a query and rewiring runtime MIR usage to that.

@RalfJung
Copy link
Member

RalfJung commented Aug 21, 2022

The optimized_mir query is only used for runtime MIR, I think. But maybe that changed again. The hierarchy of MIR queries is historically an underdocumented mess, not sure if it improved over the last year.

But I am pretty sure that there is a fork in the road somewhere for MIR (where it becomes CTFE/runtime only), and we should be able to use that here.

@RalfJung
Copy link
Member

Yeah looks like mir_drops_elaborated_and_const_checked is the last MIR that is shared, and then mir_for_ctfe clones that while optimized_mir steals it.

@RalfJung
Copy link
Member

It is kind of a crude hack to have 'implementation' passes in optimized_mir, but it might be the best solution for this particular intrinsic.

@rustbot
Copy link
Collaborator

rustbot commented Aug 22, 2022

Some changes occurred to MIR optimizations

cc @rust-lang/wg-mir-opt

Copy link
Contributor

@oli-obk oli-obk left a comment

Choose a reason for hiding this comment

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

yea, I like this variant of doing it on the MIR

compiler/rustc_mir_transform/src/lib.rs Outdated Show resolved Hide resolved
@fee1-dead fee1-dead force-pushed the const_eval_select_real_intrinsic branch from 651e0b0 to 0d03c62 Compare August 22, 2022 10:47
@oli-obk
Copy link
Contributor

oli-obk commented Aug 22, 2022

@bors r+

@bors
Copy link
Contributor

bors commented Aug 22, 2022

📌 Commit 0d03c6273e96b843d88afb14fd68d4310a6e29c3 has been approved by oli-obk

It is now in the queue for this repository.

@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 Aug 22, 2022
@fee1-dead
Copy link
Member Author

@bors r- There was a test that changed to a no-op when I was debugging. I need to fix that

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Aug 22, 2022
@fee1-dead fee1-dead force-pushed the const_eval_select_real_intrinsic branch from cf3fc5a to 89ebd65 Compare September 3, 2022 16:52
@bors
Copy link
Contributor

bors commented Sep 4, 2022

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

@fee1-dead fee1-dead force-pushed the const_eval_select_real_intrinsic branch from 89ebd65 to e87f7e3 Compare September 4, 2022 12:17
@RalfJung
Copy link
Member

RalfJung commented Sep 4, 2022

@bors delegate+

bors r=oli-obk,RalfJung once CI is green

@bors
Copy link
Contributor

bors commented Sep 4, 2022

✌️ @fee1-dead can now approve this pull request

@fee1-dead fee1-dead force-pushed the const_eval_select_real_intrinsic branch from e87f7e3 to 65b685e Compare September 4, 2022 12:35
@fee1-dead
Copy link
Member Author

@bors r=oli-obk,RalfJung

@bors
Copy link
Contributor

bors commented Sep 4, 2022

📌 Commit 65b685e has been approved by oli-obk,RalfJung

It is now in the queue for this repository.

@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 4, 2022
@bors
Copy link
Contributor

bors commented Sep 5, 2022

⌛ Testing commit 65b685e with merge 9358d09...

@bors
Copy link
Contributor

bors commented Sep 5, 2022

☀️ Test successful - checks-actions
Approved by: oli-obk,RalfJung
Pushing 9358d09 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (9358d09): 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.

mean1 range count2
Regressions ❌
(primary)
0.8% [0.3%, 1.4%] 12
Regressions ❌
(secondary)
2.4% [0.2%, 4.1%] 9
Improvements ✅
(primary)
-1.2% [-3.0%, -0.6%] 7
Improvements ✅
(secondary)
-1.4% [-1.6%, -1.0%] 10
All ❌✅ (primary) 0.1% [-3.0%, 1.4%] 19

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.

mean1 range count2
Regressions ❌
(primary)
9.8% [9.8%, 9.8%] 1
Regressions ❌
(secondary)
2.3% [1.4%, 2.9%] 3
Improvements ✅
(primary)
-3.3% [-3.3%, -3.3%] 1
Improvements ✅
(secondary)
-3.6% [-4.6%, -2.6%] 2
All ❌✅ (primary) 3.2% [-3.3%, 9.8%] 2

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.

mean1 range count2
Regressions ❌
(primary)
- - 0
Regressions ❌
(secondary)
2.4% [1.7%, 3.8%] 7
Improvements ✅
(primary)
-2.7% [-2.7%, -2.7%] 1
Improvements ✅
(secondary)
- - 0
All ❌✅ (primary) -2.7% [-2.7%, -2.7%] 1

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added the perf-regression Performance regression. label Sep 5, 2022
@fee1-dead fee1-dead deleted the const_eval_select_real_intrinsic branch September 5, 2022 08:24
@pnkfelix
Copy link
Member

pnkfelix commented Sep 14, 2022

Visiting for weekly performance triage.

Many of the reported regressions are being classified as noise from recently arising bimodalities in certain benchmarks.

But, the regression to ripgrep does look like it might be legitimate, at least from skimming its graph and zooming in.

Not marking as triaged, not yet.

@oli-obk
Copy link
Contributor

oli-obk commented Sep 16, 2022

ripgrep only regressed in LLVM, a bit later it got improved (in llvm) by a targetted placement of #[inline]. So maybe this is just inlining noise and we can get the perf back by sprinkling #[inline] at the functions modified in this PR

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. T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. T-libs Relevant to the library team, which will review and decide on the PR/issue.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

panic msg for slicing used to contain path to user's code, now contains path to core