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

Make unconditional_recursion work across function boundaries #75067

Closed
wants to merge 8 commits into from
Closed

Make unconditional_recursion work across function boundaries #75067

wants to merge 8 commits into from

Conversation

jonas-schievink
Copy link
Contributor

@jonas-schievink jonas-schievink commented Aug 2, 2020

First step towards #57965

@rust-highfive
Copy link
Collaborator

r? @oli-obk

(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 Aug 2, 2020
@jonas-schievink
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 2, 2020

⌛ Trying commit 6becae3d4de52eabf72d7b69f006573ddfecf267 with merge de45839e975f8517340a4e9a2c1cee0a92e4b812...

@bors
Copy link
Contributor

bors commented Aug 2, 2020

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

@rust-timer
Copy link
Collaborator

Queued de45839e975f8517340a4e9a2c1cee0a92e4b812 with parent a99ae95, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (de45839e975f8517340a4e9a2c1cee0a92e4b812): 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

@jonas-schievink
Copy link
Contributor Author

I've pushed a new commit that implements this in a better way, but for some reason it breaks all the incremental tests

Copy link
Contributor

@lcnr lcnr left a comment

Choose a reason for hiding this comment

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

from tcx.ensure():

/// Ensure that either this query has all green inputs or been executed.

So if inevitable_calls is green and mir_const is not, we actually don't execute inevitable_calls. As we do not cache it on disk, this would mean that when we later need the actual query content, we do have to recompute it, but at this point mir_built has already been stolen afaict.

I think we can either cache this query on disk (which is probably quite costly) or not use ensure in mir_const 🤔

src/librustc_mir/lints.rs Outdated Show resolved Hide resolved
@jonas-schievink
Copy link
Contributor Author

Thanks, that fixed the issue!

@jonas-schievink
Copy link
Contributor Author

Lets run perf again with the query in place.

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 22, 2020

⌛ Trying commit 95484733cd28cbf411a16c68f6a25cc1a8d38ed9 with merge 89143ca40dfdf0be97901f1853b15fe7a8e83a23...

@bors
Copy link
Contributor

bors commented Aug 22, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 89143ca40dfdf0be97901f1853b15fe7a8e83a23 (89143ca40dfdf0be97901f1853b15fe7a8e83a23)

@rust-timer
Copy link
Collaborator

Queued 89143ca40dfdf0be97901f1853b15fe7a8e83a23 with parent 108e90c, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (89143ca40dfdf0be97901f1853b15fe7a8e83a23): 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

@jonas-schievink
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 23, 2020

⌛ Trying commit f537570bae0605b2c6749ba9b16088720e2ec771 with merge d8aa519edb0359cf70d42b14771e587f3a6bc4ca...

@bors
Copy link
Contributor

bors commented Aug 23, 2020

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

@rust-timer
Copy link
Collaborator

Queued d8aa519edb0359cf70d42b14771e587f3a6bc4ca with parent 663d2f5, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (d8aa519edb0359cf70d42b14771e587f3a6bc4ca): 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

@bjorn3
Copy link
Member

bjorn3 commented Aug 23, 2020

Better than the previous perf run, but still a significant regression. (up to 8%)


// All callees that are guaranteed to be reached by every successor will also be reached by
// `bb`. Compute the intersection.
let successors = relevant_successors.copied();
Copy link
Contributor

@lcnr lcnr Aug 23, 2020

Choose a reason for hiding this comment

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

nit: style

this copied seems somewhat weird, can we instead match on terminator.kind in the above match and directly iterate by value?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

The SwitchInt targets is a Vec, otherwise this would work.

) -> &'tcx [(DefId, SubstsRef<'tcx>, &'tcx [Span])] {
tcx.arena.alloc_from_iter(
find_inevitable_calls(tcx, key)
.map(|(callee, spans)| (callee.def_id, callee.substs, &*tcx.arena.alloc_slice(&spans))),
Copy link
Contributor

Choose a reason for hiding this comment

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

We do allocate a lot to have the correct spans here. I think it would make a lot of sense to do a perf run without storing the relevant spans and only mention the function header of used functions in the lint.

And if that reduces the perf impact using an ArrayVec and only storing a limited number of spans or using a SmallVec might be interesting.

fn find_inevitable_calls<'tcx>(
tcx: TyCtxt<'tcx>,
def_id: DefId,
) -> impl Iterator<Item = (Callee<'tcx>, Vec<Span>)> {
Copy link
Contributor

Choose a reason for hiding this comment

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

Suggested change
) -> impl Iterator<Item = (Callee<'tcx>, Vec<Span>)> {
) -> Option<impl Iterator<Item = (Callee<'tcx>, Vec<Span>)>> {

nit: might be slightly more efficient and imo cleaner

@jonas-schievink
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 23, 2020

⌛ Trying commit 94dc317f8b684b47db0af3c09f94bf11393cb63e with merge 55691358cfa29310103a6ec5c25e35f0f611abc6...

@bors
Copy link
Contributor

bors commented Aug 23, 2020

☀️ Try build successful - checks-actions, checks-azure
Build commit: 55691358cfa29310103a6ec5c25e35f0f611abc6 (55691358cfa29310103a6ec5c25e35f0f611abc6)

@rust-timer
Copy link
Collaborator

Queued 55691358cfa29310103a6ec5c25e35f0f611abc6 with parent 2342cc3, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (55691358cfa29310103a6ec5c25e35f0f611abc6): 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

@jonas-schievink
Copy link
Contributor Author

jonas-schievink commented Aug 23, 2020

No changes from not tracking call spans. Most of the perf regressions seem to be due to more queries being run (but we shouldn't really call Instance::resolve more often than before). Oh, and inevitable_calls is still a bit slow.

@jonas-schievink
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 23, 2020

🔒 Merge conflict

This pull request and the master branch diverged in a way that cannot be automatically merged. Please rebase on top of the latest master branch, and let the reviewer approve again.

How do I rebase?

Assuming self is your fork and upstream is this repository, you can resolve the conflict following these steps:

  1. git checkout recursion-lint (switch to your branch)
  2. git fetch upstream master (retrieve the latest master)
  3. git rebase upstream/master -p (rebase on top of it)
  4. Follow the on-screen instruction to resolve conflicts (check git status if you got lost).
  5. git push self recursion-lint --force-with-lease (update this PR)

You may also read Git Rebasing to Resolve Conflicts by Drew Blessing for a short tutorial.

Please avoid the "Resolve conflicts" button on GitHub. It uses git merge instead of git rebase which makes the PR commit history more difficult to read.

Sometimes step 4 will complete without asking for resolution. This is usually due to difference between how Cargo.lock conflict is handled during merge and rebase. This is normal, and you should still perform step 5 to update this PR.

Error message
CONFLICT (modify/delete): src/librustc_mir_build/lints.rs deleted in heads/homu-tmp and modified in HEAD. Version HEAD of src/librustc_mir_build/lints.rs left in tree.
Auto-merging src/librustc_mir_build/build/mod.rs
Automatic merge failed; fix conflicts and then commit the result.

@jonas-schievink
Copy link
Contributor Author

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Aug 23, 2020

⌛ Trying commit d5d1603 with merge e8af76ec43b470394ef27523cf8644cf23cd741c...

@bors
Copy link
Contributor

bors commented Aug 23, 2020

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

@rust-timer
Copy link
Collaborator

Queued e8af76ec43b470394ef27523cf8644cf23cd741c with parent d02a209, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (e8af76ec43b470394ef27523cf8644cf23cd741c): 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

@Dylan-DPC-zz
Copy link

Closing this due to inactivity. The benchmarks don't paint a good picture as well.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-review Status: Awaiting review from the assignee but also interested parties.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

8 participants