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

Query-ify Instance::resolve #67797

Merged
merged 1 commit into from
Apr 5, 2020
Merged

Conversation

Aaron1011
Copy link
Member

Split off from #65989

Instance::resolve is now a wrapper for a new resolve_instance query.
This greatly improves performance on several benchmarks

@rust-highfive
Copy link
Collaborator

r? @estebank

(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 Jan 2, 2020
@Centril
Copy link
Contributor

Centril commented Jan 2, 2020

r? @nikomatsakis cc @Zoxc @eddyb

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Jan 2, 2020

⌛ Trying commit d1eb2de827f187de057cacbcc4c62edff2b9c45a with merge 609a6dac721d35c178f8b8147e885b190fc01e35...

@bors
Copy link
Contributor

bors commented Jan 2, 2020

☀️ Try build successful - checks-azure
Build commit: 609a6dac721d35c178f8b8147e885b190fc01e35 (609a6dac721d35c178f8b8147e885b190fc01e35)

@rust-timer
Copy link
Collaborator

Queued 609a6dac721d35c178f8b8147e885b190fc01e35 with parent 0ec3706, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 609a6dac721d35c178f8b8147e885b190fc01e35, comparison URL.

@Aaron1011
Copy link
Member Author

The style-servo benchmark seems to be completely missing from the perf run

@Mark-Simulacrum
Copy link
Member

style-servo is currently broken (on master, too): "error: truncating cast: the value 4294967292 requires 32 bits but the target type is only 16 bits" (amongst others).

Copy link
Contributor

@nikomatsakis nikomatsakis left a comment

Choose a reason for hiding this comment

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

Thoughts?

};
debug!("resolve(def_id={:?}, substs={:?}) = {:?}", def_id, substs, result);
result
tcx.resolve_instance((param_env, def_id, substs))
Copy link
Contributor

Choose a reason for hiding this comment

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

Hmm, this seems like a place where canonicalization would be appropriate. We don't expect inference variables, but we do use this (I believe) without having fully erased regions, right? In that case, canonicalizing might eliminate duplicate work.

Copy link
Member Author

@Aaron1011 Aaron1011 Jan 3, 2020

Choose a reason for hiding this comment

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

I agree. However, I think #67717 is already doing canonicalization changes related to (among other things) Instance::resolve. My queryification of Instance::resolve is just a copy-paste of the existing method body, so it should be hopefully be straightforward to apply one PR on top of the other (depending on which gets merged first).

Copy link
Contributor

Choose a reason for hiding this comment

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

Heh, I just came here from reviewing #67717 to point out that it is making changes to Instance::resolve that would require canonicalization.

Copy link
Member Author

Choose a reason for hiding this comment

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

@nikomatsakis: Would you like me to add canonicalization in this PR, or should it be done in a follow-up PR after #67717 is merged?

@Zoxc
Copy link
Contributor

Zoxc commented Jan 13, 2020

Is there something blocking this PR? It holds up #67953.

@Aaron1011
Copy link
Member Author

I assumed that this was waiting on style-servo to be fixed, so that we can do a full perf run.

@nikomatsakis
Copy link
Contributor

I have been waiting until we land #67117 -- though if we want to land this first, perhaps some assertions that we don't have inference variables would suffice.

@Aaron1011
Copy link
Member Author

@nikomatsakis: I assume you meant #67717?

@nikomatsakis
Copy link
Contributor

Yes. Sorry. :)

@Aaron1011
Copy link
Member Author

Aaron1011 commented Jan 16, 2020

Now that the servo benchmarks have been fixed, can I get another perf run?

@Mark-Simulacrum
Copy link
Member

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion

@bors
Copy link
Contributor

bors commented Jan 16, 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 feature/instance-query (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 feature/instance-query --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
Auto-merging src/librustc/ty/query/keys.rs
Auto-merging src/librustc/ty/mod.rs
CONFLICT (content): Merge conflict in src/librustc/ty/mod.rs
Auto-merging src/librustc/ty/instance.rs
Auto-merging src/librustc/query/mod.rs
Automatic merge failed; fix conflicts and then commit the result.

@Aaron1011
Copy link
Member Author

@Mark-Simulacrum: I've fixed the merge conflict

@Mark-Simulacrum
Copy link
Member

@bors try

@bors
Copy link
Contributor

bors commented Jan 16, 2020

⌛ Trying commit e73f7a7af4cff1c3af953db35272bcd9812622ae with merge b3fa52e9b78a50cbeec31bbb22ea6ec6209bdd77...

@Dylan-DPC-zz Dylan-DPC-zz added the S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author. label Mar 19, 2020
@Aaron1011
Copy link
Member Author

@Dylan-DPC: This should be S-waiting-on-review - I've responded to the most recent round of review comments.

@Dylan-DPC-zz Dylan-DPC-zz 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 Mar 19, 2020
@Dylan-DPC-zz
Copy link

@Aaron1011 thanks. made the change (Btw you can change labels with rustbot if you don't have access :)

@JohnCSimon JohnCSimon 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 Mar 28, 2020
@Aaron1011
Copy link
Member Author

@JohnCSimon: See my previous comment - this should be S-waiting-on-review

@Aaron1011

This comment has been minimized.

@rustbot rustbot 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 Mar 30, 2020
@Aaron1011
Copy link
Member Author

@nikomatsakis: Are there any changes you'd like me to make, or should I just rebase this?

@nikomatsakis
Copy link
Contributor

@Aaron1011 sorry for delay. r=me when rebased.

@Aaron1011
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Apr 5, 2020

📌 Commit 63d6ef6 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 Apr 5, 2020
@bors
Copy link
Contributor

bors commented Apr 5, 2020

⌛ Testing commit 63d6ef6 with merge 84cff50957e27f6a9f18fd6f836cc35ced665e75...

@Dylan-DPC-zz
Copy link

@bors retry yield

bors added a commit to rust-lang-ci/rust that referenced this pull request Apr 5, 2020
Rollup of 5 pull requests

Successful merges:

 - rust-lang#67797 (Query-ify Instance::resolve)
 - rust-lang#70777 (Don't import integer and float modules, use assoc consts)
 - rust-lang#70795 (Keep track of position when deleting from a BTreeMap)
 - rust-lang#70812 (Do not use "nil" to refer to `()`)
 - rust-lang#70815 (Enable layout debugging for `impl Trait` type aliases)

Failed merges:

r? @ghost
@bors
Copy link
Contributor

bors commented Apr 5, 2020

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

@bors bors 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-bors Status: Waiting on bors to run and complete tests. Bors will change the label on completion. labels Apr 5, 2020
@bors bors merged commit 829154f into rust-lang:master Apr 5, 2020
@@ -1257,5 +1257,9 @@ rustc_queries! {
eval_always
desc { "looking up enabled feature gates" }
}

query resolve_instance(key: (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>)) -> Option<ty::Instance<'tcx>> {
Copy link
Member

Choose a reason for hiding this comment

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

Just spotted this: whenever you have a ty::ParamEnv and some thing referring the to same parameters it adds bounds in scope of, like (DefId, SubstsRef) here, the right thing to do is to use ty::ParamEnvAnd<(DefId, SubstsRef)>.

Doing so should result in better caching (as the bounds in scope aren't kept if they're not needed by the SubtsRef), and is more semantically meaningful.

Copy link
Member

Choose a reason for hiding this comment

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

Will do this in a drive-by commit.

@@ -296,3 +296,14 @@ impl Key for (Symbol, u32, u32) {
DUMMY_SP
}
}

impl<'tcx> Key for (ty::ParamEnv<'tcx>, DefId, SubstsRef<'tcx>) {
Copy link
Member

Choose a reason for hiding this comment

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

I guess a strong hint is that you had to add a new Key impl: generally, you shouldn't need one.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
S-waiting-on-author Status: This is awaiting some action (such as code changes or more information) from the author.
Projects
None yet
Development

Successfully merging this pull request may close these issues.