Skip to content

Enable MIR inlining#91743

Merged
bors merged 12 commits intorust-lang:masterfrom
cjgillot:enable_mir_inlining_inline_all
Jul 2, 2022
Merged

Enable MIR inlining#91743
bors merged 12 commits intorust-lang:masterfrom
cjgillot:enable_mir_inlining_inline_all

Conversation

@cjgillot
Copy link
Contributor

@cjgillot cjgillot commented Dec 10, 2021

Continuation of #82280 by @wesleywiser.

#82280 has shown nice compile time wins could be obtained by enabling MIR inlining.
Most of the issues in #81567 are now fixed,
except the interaction with polymorphization which is worked around specifically.

I believe we can proceed with enabling MIR inlining in the near future
(preferably just after beta branching, in case we discover new issues).

Steps before merging:

  • figure out the interaction with polymorphization;
  • figure out how miri should deal with extern types;
  • silence the extra arithmetic overflow warnings;
  • remove the codegen fulfilment ICE;
  • remove the type normalization ICEs while compiling nalgebra;
  • tweak the inlining threshold.

@rust-highfive
Copy link
Contributor

Some changes occured to the CTFE / Miri engine

cc @rust-lang/miri

@rust-highfive
Copy link
Contributor

r? @jackh726

(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 Dec 10, 2021
@rust-log-analyzer

This comment has been minimized.

@rust-log-analyzer

This comment has been minimized.

@cjgillot
Copy link
Contributor Author

@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 Dec 10, 2021
@bors
Copy link
Collaborator

bors commented Dec 10, 2021

⌛ Trying commit 6a4e632dd082da698d23955f33781a45a00d2e64 with merge e158c01eec3c90aaf0463f93c68c9971a0c00924...

@bors
Copy link
Collaborator

bors commented Dec 11, 2021

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

@rust-timer
Copy link
Collaborator

Queued e158c01eec3c90aaf0463f93c68c9971a0c00924 with parent 0b42dea, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (e158c01eec3c90aaf0463f93c68c9971a0c00924): comparison url.

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

  • Large improvement in instruction counts (up to -2.1% on incr-patched: empty 3072 builds of issue-46449)
  • Very large regression in instruction counts (up to 15.7% on full builds of deeply-nested-async)

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 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

@rustbot rustbot added perf-regression Performance regression. and removed S-waiting-on-perf Status: Waiting on a perf run to be completed. labels Dec 11, 2021
@cjgillot cjgillot force-pushed the enable_mir_inlining_inline_all branch from 6a4e632 to 8f5c54e Compare December 11, 2021 10:16
@rust-log-analyzer

This comment has been minimized.

@cjgillot cjgillot force-pushed the enable_mir_inlining_inline_all branch from 8f5c54e to f5a5f1c Compare December 11, 2021 10:36
@cjgillot
Copy link
Contributor Author

@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 Dec 11, 2021
@bors
Copy link
Collaborator

bors commented Dec 11, 2021

⌛ Trying commit f5a5f1c979c645cef188e0ca113d427e8dd400be with merge 82c0b57dc36973c6b38f4dcfa748798e4d019ecd...

@bors
Copy link
Collaborator

bors commented Dec 11, 2021

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

@rust-timer
Copy link
Collaborator

Queued 82c0b57dc36973c6b38f4dcfa748798e4d019ecd with parent 4a66a70, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (82c0b57dc36973c6b38f4dcfa748798e4d019ecd): comparison url.

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

  • Large improvement in instruction counts (up to -3.0% on incr-patched: empty 3072 builds of issue-46449)
  • Very large regression in instruction counts (up to 17.0% on full builds of deeply-nested-async)

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 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

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Dec 11, 2021
@matthiaskrgr
Copy link
Member

Hmm this is not showing up in the bors queue for some reason 🤔
@bors r=oli-obk

@bors
Copy link
Collaborator

bors commented Jul 1, 2022

📌 Commit cbbf06b has been approved by oli-obk

@bors
Copy link
Collaborator

bors commented Jul 2, 2022

⌛ Testing commit cbbf06b with merge 0075bb4...

@bors
Copy link
Collaborator

bors commented Jul 2, 2022

☀️ Test successful - checks-actions
Approved by: oli-obk
Pushing 0075bb4 to master...

@rust-timer
Copy link
Collaborator

Finished benchmarking commit (0075bb4): comparison url.

Instruction count

  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
1.3% 7.2% 54
Regressions 😿
(secondary)
1.7% 6.1% 68
Improvements 🎉
(primary)
-2.6% -10.0% 118
Improvements 🎉
(secondary)
-3.4% -17.3% 76
All 😿🎉 (primary) -1.4% -10.0% 172

Max RSS (memory usage)

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
2.8% 13.5% 105
Regressions 😿
(secondary)
2.8% 4.6% 61
Improvements 🎉
(primary)
-5.8% -13.4% 23
Improvements 🎉
(secondary)
-4.9% -5.7% 3
All 😿🎉 (primary) 1.3% 13.5% 128

Cycles

Results
  • Primary benchmarks: mixed results
  • Secondary benchmarks: mixed results
mean1 max count2
Regressions 😿
(primary)
2.8% 5.7% 5
Regressions 😿
(secondary)
2.4% 3.4% 16
Improvements 🎉
(primary)
-5.4% -13.8% 87
Improvements 🎉
(secondary)
-7.2% -19.0% 37
All 😿🎉 (primary) -5.0% -13.8% 92

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

Footnotes

  1. the arithmetic mean of the percent change 2 3

  2. number of relevant changes 2 3

@nnethercote
Copy link
Contributor

It's worth pointing out the improvements to compiler bootstrapping:

A: 701.356 B: 639.547 Total: -61.8 (-8.813%)

Impressive!

@therealprof
Copy link
Contributor

stm32f4-0.14.0 | opt | full | 7.16% | 37.94x

Boooooo. 😅

I guess tons of trivial code, all inlineable, is a total nightmare for the MIR inliner.

@bjorn3
Copy link
Member

bjorn3 commented Jul 18, 2022

This has improved runtime performance of cg_clif compiled programs by a lot (when compiled in release mode). For example rustc compiled using cg_clif now builds the standard library in 8 min instead of 22 min. Thanks everyone who worked on enabling this!

// CHECK: ; core::mem::replace
// CHECK-NOT: call void @llvm.memcpy
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %src, i{{.*}} 1, i1 false)
// CHECK: call void @llvm.memcpy.{{.+}}({{i8\*|ptr}} align 1 %{{.*}}, {{i8\*|ptr}} align 1 %dest, i{{.*}} 1, i1 false)
Copy link
Member

@RalfJung RalfJung Jul 22, 2022

Choose a reason for hiding this comment

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

This change made the test fail in --stage 1 (the default for ./x.py test) on my system

/home/r/src/rust/rustc.3/build/x86_64-unknown-linux-gnu/test/codegen/mem-replace-direct-memcpy/mem-replace-direct-memcpy.ll:138:2: note: possible intended match here
 call void @llvm.memcpy.p0i8.p0i8.i64(i8* align 1 %_4, i8* align 1 %src, i64 1, i1 false)
 ^

It should be src, not dest, it seems. Or it should be %{{.*}} I guess since the name seems to be unstable. The 2nd argument is the src though so the "dest" you added here makes no sense to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-mir-opt Area: MIR optimizations A-mir-opt-inlining Area: MIR inlining 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.

Projects

None yet

Development

Successfully merging this pull request may close these issues.