Stream: t-compiler/wg-mir-opt

Topic: Getting MIR inliner stable


Xavier Denis (Jul 31 2020 at 14:50, on Zulip):

I was wondering, do we have an understanding of the problems holding back the mir inliner? What will it take to get it stable? It seems like we could win a lot by having it. From what I can tell it seems to cause a lot of ICEs but I don't actually see that many issues on GH

oli (Jul 31 2020 at 15:06, on Zulip):

ICEs are solved I think, afaik it's just that LLVM regresses perf by a lot if we turn it on

oli (Jul 31 2020 at 15:08, on Zulip):

I can't find a tracking issue for this, but we have https://github.com/rust-lang/compiler-team/issues/281

Xavier Denis (Jul 31 2020 at 15:12, on Zulip):

ah so it's CGU partitioning again?

Xavier Denis (Jul 31 2020 at 15:13, on Zulip):

that's frustrating

Xavier Denis (Jul 31 2020 at 15:13, on Zulip):

good thing we have #t-compiler/wg-incr-comp now :P

Félix Fischer (Jul 31 2020 at 15:16, on Zulip):

Damned CGUs XD

Félix Fischer (Jul 31 2020 at 15:24, on Zulip):

Question: the MIR inliner gave better performance still on full (ie non-incremental) builds, right?

Félix Fischer (Jul 31 2020 at 15:24, on Zulip):

Or was it also regressing in full builds?

Félix Fischer (Jul 31 2020 at 15:25, on Zulip):

(I ask because if it were regressing in full builds, then that means that there must be something besides CGU partitioning that's making it slower than not inlining)

oli (Jul 31 2020 at 15:30, on Zulip):

full builds also do CGU partitioning

oli (Jul 31 2020 at 15:30, on Zulip):

and yes, they also regressed

Félix Fischer (Jul 31 2020 at 15:44, on Zulip):

Damn

Félix Fischer (Jul 31 2020 at 15:45, on Zulip):

Oh, okay, I think I remember now what the CGU partitioning implied for full builds

Wesley Wiser (Jul 31 2020 at 15:45, on Zulip):

deeply-nested also regressed like 10,000x in release mode because LLVM was able to do a lot more optimizations (at least that's my theory).

Félix Fischer (Jul 31 2020 at 15:45, on Zulip):

I was thinking only about the fact that in incremental you can change a lot of CGUs when recompiling

Wesley Wiser (Jul 31 2020 at 15:46, on Zulip):

https://github.com/rust-lang/rust/pull/68213

Wesley Wiser (Jul 31 2020 at 15:46, on Zulip):

For those interested

Félix Fischer (Jul 31 2020 at 15:47, on Zulip):

But in full builds the size of the generated CGUs matters a lot, and since inlining should (think) raise the sizes, that's where it can regress

Félix Fischer (Jul 31 2020 at 15:48, on Zulip):

Oh god, those regressions

Félix Fischer (Jul 31 2020 at 15:48, on Zulip):

:(

Félix Fischer (Jul 31 2020 at 15:49, on Zulip):

So Wesley: inlining should only be used for release mode, right?

Félix Fischer (Jul 31 2020 at 15:49, on Zulip):

Or should it be used in debug as well?

Félix Fischer (Jul 31 2020 at 15:49, on Zulip):

I dunno if LLVM inlines functions in debug mode

Félix Fischer (Jul 31 2020 at 15:49, on Zulip):

If it doesn't, then maybe the inlining opt only makes sense for release

Félix Fischer (Jul 31 2020 at 15:50, on Zulip):

(Because otherwise it wouldn't be taking work out of llvm)

Félix Fischer (Jul 31 2020 at 15:57, on Zulip):

(Forgot to tag you: @Wesley Wiser)

Wesley Wiser (Jul 31 2020 at 16:00, on Zulip):

Arguably yeah it should only apply in release mode but there's a fair number of debug improvements as well. issue-46449-debug for example shows an almost 9% improvement on debug full.

Félix Fischer (Jul 31 2020 at 16:01, on Zulip):

Woah

Félix Fischer (Jul 31 2020 at 16:01, on Zulip):

I guess that means llvm applies inlining even on debug level?

Félix Fischer (Jul 31 2020 at 16:02, on Zulip):

Hang on I think I can check that with a playground :thinking:

Félix Fischer (Jul 31 2020 at 16:02, on Zulip):

Brb

Wesley Wiser (Jul 31 2020 at 16:03, on Zulip):

No but inlining is a crucial optimization because it enables so many of the other optimizations to kick in.

Félix Fischer (Jul 31 2020 at 16:06, on Zulip):

Ohhhhhhhhh

Félix Fischer (Jul 31 2020 at 16:06, on Zulip):

That makes sense!

Félix Fischer (Jul 31 2020 at 16:06, on Zulip):

:D

Félix Fischer (Jul 31 2020 at 16:06, on Zulip):

And with that you can overall give llvm better and crucially... smaller IR

Wesley Wiser (Jul 31 2020 at 16:08, on Zulip):

Yeah :smile:

Last update: Sep 28 2020 at 16:00UTC