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

Fix exponential projection complexity on nested types #48296

Merged
merged 4 commits into from
Feb 25, 2018

Conversation

ishitatsuyuki
Copy link
Contributor

@ishitatsuyuki ishitatsuyuki commented Feb 17, 2018

This implements solution 1 from #38528 (comment).

The code quality was extremely poor, but it has improved during review.

Blocking issues:

  • we probably don't want a quadratic deduplication for obligations.
  • is there an alternative to deduplication?

Based on #48315.

Needs changelog. Noticable improvement on compile time is expected.

Fix #38528
Close #39684
Close #43757

@rust-highfive
Copy link
Collaborator

r? @nikomatsakis

(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 Feb 17, 2018
@ishitatsuyuki ishitatsuyuki changed the title [wip] (PoC) Fix exponential blowup on nested types [wip] (PoC) Fix exponential projection complexity on nested types Feb 17, 2018
Copy link
Contributor Author

@ishitatsuyuki ishitatsuyuki left a comment

Choose a reason for hiding this comment

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

Here are some self-reminders.

@@ -818,55 +822,74 @@ fn project_type<'cx, 'gcx, 'tcx>(
&obligation_trait_ref,
&mut candidates);

let decide_commit = |candidates: &mut ProjectionTyCandidateSet<'tcx>| {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

I have no way but to reorder this before the error handling. It looks non intuitive.

});
debug!("resulting candidate set: {:?}", candidates.vec);
if candidates.vec.len() != 1 {
candidates.ambiguous = true;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is nearly a hack.

}
};

match vtable {
match vtable.clone() {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This copy can be avoided.

@kennytm kennytm added S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. and removed S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. labels Feb 17, 2018
@ishitatsuyuki ishitatsuyuki changed the title [wip] (PoC) Fix exponential projection complexity on nested types [wip] Fix exponential projection complexity on nested types Feb 18, 2018
@ishitatsuyuki
Copy link
Contributor Author

The other part of the blowup (typeck related) is yet to be solved, but I think the code is ready for a round of review. I have removed whitespace changes and clarified the description.

@ishitatsuyuki
Copy link
Contributor Author

@kennytm A reminder for you to change the review labels.

@kennytm kennytm added S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. and removed S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. labels Feb 18, 2018
@kennytm
Copy link
Member

kennytm commented Feb 18, 2018

@bors try

Let’s do a perf check while we’re waiting for review :)

@bors
Copy link
Contributor

bors commented Feb 18, 2018

⌛ Trying commit 3d81698 with merge e35a3273278915e65cf22237f934456a55a438b6...

@kennytm
Copy link
Member

kennytm commented Feb 18, 2018

@ishitatsuyuki please remove the [wip] from the PR title if it is ready for review.

@ishitatsuyuki
Copy link
Contributor Author

Well, I'm currently tackling another part of the exponential issue (so this is WIP), but I need comments on improving the code organization.

@bors
Copy link
Contributor

bors commented Feb 18, 2018

☀️ Test successful - status-travis
State: approved= try=True

@ishitatsuyuki ishitatsuyuki changed the title [wip] Fix exponential projection complexity on nested types Fix exponential projection complexity on nested types Feb 18, 2018
@ishitatsuyuki
Copy link
Contributor Author

By deduplicating the obligations the issue is completely resolved. I'm not sure if this approach is the best way though, and I copied the dumb deduplication becuase I didn't want to implement Ord everywhere. I will fix them later.

@ishitatsuyuki
Copy link
Contributor Author

@kennytm I need another try.

@Mark-Simulacrum Mark-Simulacrum added the relnotes Marks issues that should be documented in the release notes of the next release. label Feb 18, 2018
@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Feb 18, 2018

⌛ Trying commit 4a40c55 with merge 4ac2425...

@nikomatsakis
Copy link
Contributor

@bors r+

@ishitatsuyuki -- it'd be great to add at least one of these exponential blow-up cases to the perf website so we can monitor for regressions. Perhaps @Mark-Simulacrum can walk you through it.

@bors
Copy link
Contributor

bors commented Feb 22, 2018

📌 Commit 5a2bec9 has been approved by nikomatsakis

@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 Feb 22, 2018
Manishearth added a commit to Manishearth/rust that referenced this pull request Feb 24, 2018
…sakis

Fix exponential projection complexity on nested types

This implements solution 1 from rust-lang#38528 (comment).

The code quality is currently extremely poor, but we can improve them during review.

Blocking issues:

- we probably don't want a quadratic deduplication for obligations.
- is there an alternative to deduplication?

Based on rust-lang#48315.

Needs changelog. Noticable improvement on compile time is expected.

Fix rust-lang#38528
Close rust-lang#39684
Close rust-lang#43757
bors added a commit that referenced this pull request Feb 25, 2018
Rollup of 15 pull requests

- Successful merges: #47689, #48110, #48197, #48296, #48386, #48392, #48404, #48415, #48441, #48448, #48452, #48481, #48490, #48499, #48503
- Failed merges:
@bors bors merged commit 5a2bec9 into rust-lang:master Feb 25, 2018
@ishitatsuyuki ishitatsuyuki deleted the exp-unblow branch March 1, 2018 08:56
bors pushed a commit to rust-lang-ci/rust that referenced this pull request May 21, 2021
This effectively reverts rust-lang#43546 as it seems that it does affect performance more than the PR has anticipated. Follow-up changes from rust-lang#44269 are also reverted.

This also removes the deduplication code from rust-lang#48296 as duplications were primarily coming from rust-lang#43546 and after removing that code it probably doesn't worth paying the cost of using a hash map.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
relnotes Marks issues that should be documented in the release notes of the next release. 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.

6 participants