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

Replace closures_captures and upvar_capture with closure_min_captures #82951

Merged
merged 2 commits into from Mar 19, 2021

Conversation

jenniferwills
Copy link
Member

Removed all uses of closures_captures and upvar_capture and refactored code to work with closure_min_captures. This also involved removing functions that were no longer needed like the bridge.

Closes rust-lang/project-rfc-2229#18
r? @nikomatsakis

@rust-highfive
Copy link
Collaborator

Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @nikomatsakis (or someone else) soon.

If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes.

Please see the contribution instructions for more information.

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Mar 9, 2021
@nagisa
Copy link
Member

nagisa commented Mar 9, 2021

@bors try @rust-timer queue

@rust-timer
Copy link
Collaborator

Awaiting bors try build completion.

@rustbot label: +S-waiting-on-perf

@rustbot rustbot added the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 9, 2021
@bors
Copy link
Contributor

bors commented Mar 9, 2021

⌛ Trying commit a54eefb with merge b08e4d30cf5eda2d10489d7a35a19886954075dd...

@bors
Copy link
Contributor

bors commented Mar 9, 2021

☀️ Try build successful - checks-actions
Build commit: b08e4d30cf5eda2d10489d7a35a19886954075dd (b08e4d30cf5eda2d10489d7a35a19886954075dd)

@rust-timer
Copy link
Collaborator

Queued b08e4d30cf5eda2d10489d7a35a19886954075dd with parent 3a5d45f, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit (b08e4d30cf5eda2d10489d7a35a19886954075dd): 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
@rustbot label: +S-waiting-on-review -S-waiting-on-perf

@rustbot rustbot removed the S-waiting-on-perf Status: Waiting on a perf run to be completed. label Mar 10, 2021
@arora-aman
Copy link
Member

Some degree of the improvement can be accounted for the fact that there is less information in typechk results, and therefore there is less to hash when building the incr cache.

I'm not sure where the increase in incr count is coming from, it is mostly <1%. Maybe it's because how the data is now organized which now requires us to access two data structrues instead of just one and also we create an iterator so there are added checks for that?

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.

Hmm, this had some subtle bits in it! But I think it's correct.

@@ -693,7 +676,7 @@ impl<'tcx> TypeckResults<'tcx> {
impl<'a, 'tcx> HashStable<StableHashingContext<'a>> for TypeckResults<'tcx> {
fn hash_stable(&self, hcx: &mut StableHashingContext<'a>, hasher: &mut StableHasher) {
let ty::TypeckResults {
hir_owner,
hir_owner: _,
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 used to be hashed as part of hashing the upvar_capture_map (we asserted it was equal to something we hashed). I'm not sure if it needs to be hashed, but it's also not obvious that it doesn't. I'd rather add a line like this:

hcx.local_def_path_hash(hir_owner);

(Unless you know a reason not to, of course!)

Copy link
Member

Choose a reason for hiding this comment

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

I'd assume it still does get hashed, upvar_capture_map got replaced by closure_min_capture map, which contains places, which represent their start(PlaceBase) using an UpvarId. These upvar ids are the same as those in the upvar_capture_map, they are now associated with other information like projections, types etc.

@nikomatsakis
Copy link
Contributor

r=me, but I'd like to see the hashing change

@bors delegate+

@bors
Copy link
Contributor

bors commented Mar 12, 2021

✌️ @jenniferwills can now approve this pull request

jenniferwills and others added 2 commits March 18, 2021 20:45
make changes to liveness to use closure_min_captures

use different span

borrow check uses new structures

rename to CapturedPlace

stop using upvar_capture in regionck

remove the bridge

cleanup from rebase + remove the upvar_capture reference from mutability_errors.rs

remove line from livenes test

make our unused var checking more consistent

update tests

adding more warnings to the tests

move is_ancestor_or_same_capture to rustc_middle/ty

update names to reflect the closures

add FIXME

check that all captures are immutable borrows before returning

add surrounding if statement like the original

move var out of the loop and rename

Co-authored-by: Logan Mosier <logmosier@gmail.com>
Co-authored-by: Roxane Fruytier <roxane.fruytier@hotmail.com>
@jenniferwills
Copy link
Member Author

@bors r=nikomatsakis

@bors
Copy link
Contributor

bors commented Mar 19, 2021

📌 Commit 88db752 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 Mar 19, 2021
@bors
Copy link
Contributor

bors commented Mar 19, 2021

⌛ Testing commit 88db752 with merge cebc8fe...

@bors
Copy link
Contributor

bors commented Mar 19, 2021

☀️ Test successful - checks-actions
Approved by: nikomatsakis
Pushing cebc8fe to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Mar 19, 2021
@bors bors merged commit cebc8fe into rust-lang:master Mar 19, 2021
@rustbot rustbot added this to the 1.52.0 milestone Mar 19, 2021
@rylev
Copy link
Member

rylev commented Mar 23, 2021

@jenniferwills @nikomatsakis After merging another performance run was done on this PR which shows regressions larger than 1%, meaning we might want to look into it. The regression is coming in incremental builds in the encode_query_results_for query which explains why this is impacting incremental builds. I personally don't see what changes could have caused a regression like this though. Any thoughts?

@nikomatsakis
Copy link
Contributor

@rylev hmm, offhand no -- is this doing more encoding than previously? I'd actually expect less encoding work, since we removed some fields I think.

@arora-aman
Copy link
Member

Only thing that has changed since the first perf run is that now we explicitly hash the hir_owner defid, this was previously being hashed part of the entries in the upvar_capture_map. I'd assume that added the extra work since the last run, though I'm not sure if that should be that significant. As @nikomatsakis said, overall we are still doing less encoding so I'm not sure why there is negative impact :/

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
merged-by-bors This PR was explicitly merged by bors. 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.

Use min capture results everywhere
9 participants