Skip to content

interpret: don't rely on ScalarPair for overflowed arithmetic#98627

Merged
bors merged 2 commits into
rust-lang:masterfrom
RalfJung:interpret-arith
Jul 4, 2022
Merged

interpret: don't rely on ScalarPair for overflowed arithmetic#98627
bors merged 2 commits into
rust-lang:masterfrom
RalfJung:interpret-arith

Conversation

@RalfJung

Copy link
Copy Markdown
Member

This is for #97861.
Cc @eddyb

I would like to avoid making this depend on dest.layout.abi to avoid a branch that we are not usually covering both sides of. Though OTOH this seems like fairly straight-forward code. But let's benchmark this option first to see how bad that extra force_allocation really is.

@rustbot rustbot added the T-compiler Relevant to the compiler team, which will review and decide on the PR/issue. label Jun 28, 2022
@rustbot

rustbot commented Jun 28, 2022

Copy link
Copy Markdown
Collaborator

Some changes occurred to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @lcnr

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

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Jun 28, 2022
@RalfJung

Copy link
Copy Markdown
Member Author

@bors try @rust-timer queue

@rust-timer

Copy link
Copy Markdown
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 Jun 28, 2022
@bors

bors commented Jun 28, 2022

Copy link
Copy Markdown
Collaborator

⌛ Trying commit a863894797f329841331df301bdaf275c0e3ff94 with merge 57aca588d42161a2fd53f97a85fc4eb9f62f8e38...

@bors

bors commented Jun 28, 2022

Copy link
Copy Markdown
Collaborator

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

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued 57aca588d42161a2fd53f97a85fc4eb9f62f8e38 with parent baf382e, future comparison URL.

@RalfJung

Copy link
Copy Markdown
Member Author

That is strange, is this making const-prop worse?

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (57aca588d42161a2fd53f97a85fc4eb9f62f8e38): comparison url.

Instruction count

  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
0.2% 0.2% 1
Regressions 😿
(secondary)
7.7% 8.8% 7
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
-0.6% -0.7% 6
All 😿🎉 (primary) 0.2% 0.2% 1

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
0.3% 0.3% 1
Regressions 😿
(secondary)
3.0% 3.0% 1
Improvements 🎉
(primary)
-1.9% -1.9% 1
Improvements 🎉
(secondary)
-2.3% -2.3% 1
All 😿🎉 (primary) -0.8% -1.9% 2

Cycles

Results
  • Primary benchmarks: no relevant changes found
  • Secondary benchmarks: 😿 relevant regressions found
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
8.6% 11.6% 7
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) N/A N/A 0

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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Jun 28, 2022
@bjorn3

bjorn3 commented Jun 28, 2022

Copy link
Copy Markdown
Member

Cg_clif makes the same assumption with respect to the ScalarPair ABI being used for CheckedBinOp.

@RalfJung

Copy link
Copy Markdown
Member Author

As expected, the CTFE benchmark is not happy.

We probably should go with @eddyb's proposal of checking the dest.layout.abi then... but maybe also fall back to the slow path in debug builds, just to ensure it remains covered? OTOH then maybe we don't cover the fast path enough.^^

@oli-obk

oli-obk commented Jun 28, 2022

Copy link
Copy Markdown
Contributor

Oh yea this affects const prop. Const prop likely doesn't handle locals backed by an alloc properly and optimizes/lints less

@RalfJung

Copy link
Copy Markdown
Member Author

All right, I brought back the old code path. It is not used in debug builds.

@RalfJung

Copy link
Copy Markdown
Member Author

Aand I guess CI is using a debug build. Argh.
Is there the equivalent of // ignore-debug for run-make tests?

@rust-log-analyzer

This comment has been minimized.

@RalfJung

RalfJung commented Jul 3, 2022

Copy link
Copy Markdown
Member Author

Well, this should fix CI. The only problem is that now the new code path is fully untested...

@lcnr

lcnr commented Jul 4, 2022

Copy link
Copy Markdown
Contributor

i am fine with that

r=me unless you want to try something else

let pair = Immediate::ScalarPair(val.into(), Scalar::from_bool(overflowed).into());
self.write_immediate(pair, dest)?;
} else {
// With randomized layout, `(int, bool)` might cease to be a `ScalarPair`, so we have to

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.

maybe explicitly assert that we're using -Zrandomize-layout (or however the flag is called) here?

@RalfJung

RalfJung commented Jul 4, 2022

Copy link
Copy Markdown
Member Author

@bors r=lcnr

@Kixiron I hope you'll make this covered by tests soon? :D

@bors

bors commented Jul 4, 2022

Copy link
Copy Markdown
Collaborator

📌 Commit 0850bad has been approved by lcnr

@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 Jul 4, 2022
@Kixiron

Kixiron commented Jul 4, 2022

Copy link
Copy Markdown
Contributor

Sure, I can totally try to test layout randomization in a later PR

@bors

bors commented Jul 4, 2022

Copy link
Copy Markdown
Collaborator

⌛ Testing commit 0850bad with merge 27eb6d7...

@bors

bors commented Jul 4, 2022

Copy link
Copy Markdown
Collaborator

☀️ Test successful - checks-actions
Approved by: lcnr
Pushing 27eb6d7 to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Jul 4, 2022
@bors bors merged commit 27eb6d7 into rust-lang:master Jul 4, 2022
@rustbot rustbot added this to the 1.64.0 milestone Jul 4, 2022
@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking commit (27eb6d7): comparison url.

Instruction count

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

Max RSS (memory usage)

Results
  • Primary benchmarks: 🎉 relevant improvement found
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
N/A N/A 0
Regressions 😿
(secondary)
2.0% 2.0% 1
Improvements 🎉
(primary)
-1.5% -1.5% 1
Improvements 🎉
(secondary)
-4.7% -4.7% 1
All 😿🎉 (primary) -1.5% -1.5% 1

Cycles

Results
  • Primary benchmarks: 😿 relevant regression found
  • Secondary benchmarks: no relevant changes found
mean1 max count2
Regressions 😿
(primary)
3.0% 3.0% 1
Regressions 😿
(secondary)
N/A N/A 0
Improvements 🎉
(primary)
N/A N/A 0
Improvements 🎉
(secondary)
N/A N/A 0
All 😿🎉 (primary) 3.0% 3.0% 1

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

@rustbot label: -perf-regression

Footnotes

  1. the arithmetic mean of the percent change 2

  2. number of relevant changes 2

@rustbot rustbot removed the perf-regression Performance regression. label Jul 5, 2022
@RalfJung RalfJung deleted the interpret-arith branch July 6, 2022 02:27
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. 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.

10 participants