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

move Deaggregate pass to post_borrowck_cleanup #71946

Closed
wants to merge 6 commits into from

Conversation

RalfJung
Copy link
Member

@RalfJung RalfJung commented May 6, 2020

In #70073 MIR pass handling got reorganized, but with the goal of not changing behavior (except for disabling some optimizations on opt-level = 0). But there we realized that the Deaggregator pass, while conceptually more of a "cleanup" pass (and one that should be run before optimizations), was run in the middle of the optimization chain. Likely this is an accident of history, so I suggest we try and clean that up by making it a proper cleanup pass.

This does change mir-opt output, likely because deaggregation now runs before const-prop instead of after. I am not sure if that is acceptable, desirable, or a problem.

r? @oli-obk @wesleywiser @eddyb @rust-lang/wg-mir-opt

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label May 6, 2020
@RalfJung
Copy link
Member Author

RalfJung commented May 6, 2020

I guess it is worth checking if this has any perf implications.
@bors rollup=never try
@rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented May 6, 2020

⌛ Trying commit 7572d47f61795461aeb9aacbace6152a666ae509 with merge 89530668eb34ae5856fd9aabf52a7c8afaa08808...

@RalfJung
Copy link
Member Author

RalfJung commented May 6, 2020

Curiously, this causes incremental test suite failures -- I am not sure what that is about, and have no idea how to debug it.

@oli-obk
Copy link
Contributor

oli-obk commented May 6, 2020

Hehe, I think that is because the incremental tests expect the changes done to not have an effect on MIR, but the "no effect" only existed because const prop eliminated all changes between the two variants. This is not true anymore due to the const prop regression.

@wesleywiser
Copy link
Member

I recall removing annotations from the incremental tests indicating that some changes should have an effect on the optimized MIR when we switched const prop on by default. So that sounds correct to me.

@rust-highfive

This comment has been minimized.

@RalfJung
Copy link
Member Author

RalfJung commented May 6, 2020

That's good, it means we have just one side-effect of this change and not two. :D

So is this ConstProp effect something that we should fix before landing this PR? I'm afraid I won't have time to look into that, but I am happy to let this PR sit until someone gets around to that (or else turn it into an issue if we think that might take longer).

@bors
Copy link
Contributor

bors commented May 6, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 89530668eb34ae5856fd9aabf52a7c8afaa08808 (89530668eb34ae5856fd9aabf52a7c8afaa08808)

@rust-timer
Copy link
Collaborator

Queued 89530668eb34ae5856fd9aabf52a7c8afaa08808 with parent 43271a3, future comparison URL.

@oli-obk
Copy link
Contributor

oli-obk commented May 6, 2020

So is this ConstProp effect something that we should fix before landing this PR?

I think we should fix it. This PR breaks all or at least most of our aggregate + const prop tests. Since we now have in-block const prop even for variables, we can actually write tests for this situation without your PR, so I'm going to do this change independently from your PR, get that merged, and then we merge your PR (whose diff should become much simpler after that).

@RalfJung
Copy link
Member Author

RalfJung commented May 6, 2020

@oli-obk all right, sounds good!

@RalfJung RalfJung added the S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. label May 6, 2020
@oli-obk
Copy link
Contributor

oli-obk commented May 6, 2020

🎉 #71953

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 89530668eb34ae5856fd9aabf52a7c8afaa08808, comparison URL.

@RalfJung
Copy link
Member Author

RalfJung commented May 6, 2020

Wow that's a serious perf regression for servo-opt, let's hope it gets fixed by your patch @oli-obk.

@oli-obk
Copy link
Contributor

oli-obk commented May 7, 2020

:( I'm just getting bad gateway errors when trying to open the perf result

@wesleywiser
Copy link
Member

It's working now and ouch!

@RalfJung
Copy link
Member Author

RalfJung commented May 7, 2020

I have no idea how to read that "detailed query" page, is there a guide for that somewhere? Somehow there's a "totals" row that sums up to either 136.02% of the time or 56.7% of something without a column header, where I'd expect a total to be 100% of whatever it is, so I am already lost in that row.

@RalfJung
Copy link
Member Author

RalfJung commented May 7, 2020

Oh wait maybe that weird Δ is not part of the GUI but the column header? I thought it indicates what things are sorted by (upwards arrow), but maybe it's the letter Delta? That would answer one of 3 questions about the first two rows of this table -- I didn't dare go further yet.^^

@Mark-Simulacrum
Copy link
Member

Yes, that's intended to be a delta -- I'm forgetting now why it's not just written out...

The total time header (e.g. 136.02% in this case) is the amount of time self profile claims it took divided by the amount of time that the cpu clock statistic gave us -- basically wall clock but accounting for parallelism. It can mostly be ignored, just gives you a rough sense how much time we're likely to be "off" by, though I can't tell you why we're sometimes off by so much.

@RalfJung
Copy link
Member Author

RalfJung commented May 7, 2020

Okay. But why are there three Delta columns that are very different? Is that delta of time, delta of"full executions" (are there "partial executions"?), and "loading delta" (whatever that is)?

The first delta could also be delta of "percent of time" as that's the column to its left, not sure.

@RalfJung
Copy link
Member Author

RalfJung commented May 7, 2020

Let's move this to a separate issue: rust-lang/rustc-perf#648

@wesleywiser
Copy link
Member

rust-lang/compiler-team#281 is really getting more and more important

Adding this to my examples list.

@@ -74,7 +74,7 @@ impl<'mir, 'tcx: 'mir, M: Machine<'mir, 'tcx>> InterpCx<'mir, 'tcx, M> {
Ok(true)
}

fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
crate fn statement(&mut self, stmt: &mir::Statement<'tcx>) -> InterpResult<'tcx> {
Copy link
Member Author

Choose a reason for hiding this comment

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

Hm... of it's (semi-)public, maybe it should have a doc comment?

Also for consistency, terminator should probably get the same treatment.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 5, 2020

ok... this is causing stage 2 failures now... Idk how that change could be misoptimizing anything and I won't have time to dig into it until some time next week.

@RalfJung
Copy link
Member Author

RalfJung commented Jun 5, 2020

Maybe it is indeed better to make that a separate PR, then.

(Quite amazing how hard it can be to reorder these passes.^^)

@RalfJung RalfJung added S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Jun 6, 2020
@oli-obk
Copy link
Contributor

oli-obk commented Jun 6, 2020

The change would likely not be misoptimizing anything without moving the deaggregation pass as early as you did

@oli-obk
Copy link
Contributor

oli-obk commented Jun 6, 2020

but we can move the independent things out of this PR, sure

@RalfJung
Copy link
Member Author

RalfJung commented Jun 6, 2020

Whatever you prefer. If you want you can also just make a PR yourself with this branch, at this point you did much more of the work than I did and this is way out of my league anyway.^^

@oli-obk oli-obk added the A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html label Jun 6, 2020
@wesleywiser
Copy link
Member

If you don't mind, I'd be happy to pull the "remove const prop interning" change into a separate PR. I suspect we can close a number of ICE issues with that change.

@oli-obk
Copy link
Contributor

oli-obk commented Jun 6, 2020

That would be great! Thanks

@bors
Copy link
Contributor

bors commented Jun 7, 2020

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

@RalfJung
Copy link
Member Author

Does #71911 (comment) mean we should stop attempting this reordering?

@oli-obk
Copy link
Contributor

oli-obk commented Jun 10, 2020

I opened #73203

I don't think we should stop this PR, the discussion is a separate one that we'll be able to resolve in either direction even with this change.

@RalfJung
Copy link
Member Author

Status: blocked on #73130.

RalfJung added a commit to RalfJung/rust that referenced this pull request Jun 19, 2020
…ndirects, r=oli-obk

Remove const prop for indirects

This was only used by one mir-opt test and since it causes buggy behavior under `-Zmir-opt-level=2`, it seems like we should remove it.

This was split out from rust-lang#71946.

Closes rust-lang#72679
Closes rust-lang#72372
Closes rust-lang#72285
@RalfJung
Copy link
Member Author

#73130 landed. @oli-obk I don't know how many of your patches that included, which commits should be rebased?

@oli-obk
Copy link
Contributor

oli-obk commented Jun 20, 2020

I can do the rebase. Since I still can't modify this PR I'll do what you suggested earlier

If you want you can also just make a PR yourself with this branch

@RalfJung
Copy link
Member Author

Yeah I'm happy for you to take over. :)
Closing this PR then.

@RalfJung RalfJung closed this Jun 20, 2020
@RalfJung RalfJung deleted the deaggregate-is-cleanup branch June 23, 2020 17:05
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 11, 2020
…leywiser

move Deaggregate pass to post_borrowck_cleanup

Reopen of rust-lang#71946

Only the second commit is from this PR, the other commit is a bugfix that's in the process of getting merged. I'll rebase once that's done

In rust-lang#70073 MIR pass handling got reorganized, but with the goal of not changing behavior (except for disabling some optimizations on opt-level = 0). But there we realized that the Deaggregator pass, while conceptually more of a "cleanup" pass (and one that should be run before optimizations), was run in the middle of the optimization chain. Likely this is an accident of history, so I suggest we try and clean that up by making it a proper cleanup pass.

This does change mir-opt output, because deaggregation now runs before const-prop instead of after.

r? @wesleywiser @rust-lang/wg-mir-opt

cc @RalfJung
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-MIR Area: Mid-level IR (MIR) - https://blog.rust-lang.org/2016/04/19/MIR.html S-blocked Status: Marked as blocked ❌ on something else such as an RFC or other implementation work.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

8 participants