Skip to content

Replace a recursive algorithm with an iterative one and a stack.#74983

Merged
bors merged 1 commit into
rust-lang:masterfrom
oli-obk:mir_opt_goto_chain
Aug 1, 2020
Merged

Replace a recursive algorithm with an iterative one and a stack.#74983
bors merged 1 commit into
rust-lang:masterfrom
oli-obk:mir_opt_goto_chain

Conversation

@oli-obk

@oli-obk oli-obk commented Jul 31, 2020

Copy link
Copy Markdown
Contributor

fixes #74931

@rust-highfive

Copy link
Copy Markdown
Contributor

r? @ecstatic-morse

(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 Jul 31, 2020
@Mark-Simulacrum

Copy link
Copy Markdown
Member

@bors try @rust-timer queue

Seems not unlikely to have some perf effects.

@rust-timer

Copy link
Copy Markdown
Collaborator

Awaiting bors try build completion

@bors

bors commented Jul 31, 2020

Copy link
Copy Markdown
Collaborator

⌛ Trying commit ac5b2b0a2a6d526901b412f07651885be3c7f1f9 with merge 7ecf4177219d2b3082e0d5ee04edff8af3e1e80b...

@bors

bors commented Jul 31, 2020

Copy link
Copy Markdown
Collaborator

☀️ Try build successful - checks-actions, checks-azure
Build commit: 7ecf4177219d2b3082e0d5ee04edff8af3e1e80b (7ecf4177219d2b3082e0d5ee04edff8af3e1e80b)

@rust-timer

Copy link
Copy Markdown
Collaborator

Queued 7ecf4177219d2b3082e0d5ee04edff8af3e1e80b with parent 62f9aa9, future comparison URL.

@ecstatic-morse ecstatic-morse left a comment

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.

Thanks for doing this @oli-obk. I remember looking at this code early on and wondering if it was going to ruin someone's day 😄. This is a pretty straightforward translation of the recursive version, so I feel good about it even though I left some questions.

Comment thread src/librustc_mir/transform/simplify.rs Outdated
Comment thread src/librustc_mir/transform/simplify.rs Outdated

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.

Preexisting I know, but why do we only mark the MIR as changed if current != target? If current == target then we are inserting a self-loop, but it's possible for this to represent a change in the MIR if we had a cycle involving several Gotos.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

I have learned the hard way that tinkering with this code is not a good idea XD But I've also learned that you either break it completely or not at all, there's no middle ground, so I guess i can do more experimentation

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

oh well, it worked :D

@ecstatic-morse ecstatic-morse Jul 31, 2020

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.

If you don't wanna lump it into this PR, that's fine too. It just didn't make sense to me.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

it's already in this PR ;)

Comment thread src/librustc_mir/transform/simplify.rs Outdated

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.

Why the SmallVec here? In the common case, start will not refer to a Goto with no statements, so terminators will be empty.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

anecdotal evidence showed me many single-step goto chains (I had logging on during libcore builds). But we can also just go ahead and benchmark Vec vs SmallVec<[_; 1]> and maybe some other default sizes.

@ecstatic-morse ecstatic-morse Jul 31, 2020

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.

I'm satisfied with that. It shouldn't matter much either way, maybe leave a comment?

@rust-timer

Copy link
Copy Markdown
Collaborator

Finished benchmarking try commit (7ecf4177219d2b3082e0d5ee04edff8af3e1e80b): comparison url.

Benchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. Please note that if the perf results are neutral, you should likely undo the rollup=never given below by specifying rollup- to bors.

Importantly, though, if the results of this run are non-neutral do not roll this PR up -- it will mask other regressions or improvements in the roll up.

@bors rollup=never

@ecstatic-morse

Copy link
Copy Markdown
Contributor

@bors rollup

@oli-obk r=me when you're happy

@oli-obk oli-obk force-pushed the mir_opt_goto_chain branch from 49d0c9a to aba0251 Compare August 1, 2020 05:20
@oli-obk

oli-obk commented Aug 1, 2020

Copy link
Copy Markdown
Contributor Author

@bors r=ecstatic-morse

@bors

bors commented Aug 1, 2020

Copy link
Copy Markdown
Collaborator

📌 Commit aba0251 has been approved by ecstatic-morse

@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 1, 2020
bors added a commit to rust-lang-ci/rust that referenced this pull request Aug 1, 2020
…arth

Rollup of 6 pull requests

Successful merges:

 - rust-lang#74977 (Clean up E0741 error explanation)
 - rust-lang#74981 (Some fixes for `plugin.md` in unstable-book)
 - rust-lang#74983 (Replace a recursive algorithm with an iterative one and a stack.)
 - rust-lang#74995 (Update the WASI libc build to LLVM 10.)
 - rust-lang#74996 (submodules: update cargo from 974eb438d to 2d5c2381e)
 - rust-lang#75007 (Clean up E0743 explanation)

Failed merges:

r? @ghost
@bors bors merged commit 6951581 into rust-lang:master Aug 1, 2020
@oli-obk oli-obk deleted the mir_opt_goto_chain branch August 2, 2020 06:18
@cuviper cuviper added this to the 1.47.0 milestone May 2, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

S-waiting-on-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

"thread 'rustc' has overflowed its stack" introduced in 1.45.0

7 participants