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

Collector tweaks #67756

Merged
merged 4 commits into from
Jan 11, 2020
Merged

Collector tweaks #67756

merged 4 commits into from
Jan 11, 2020

Conversation

Zoxc
Copy link
Contributor

@Zoxc Zoxc commented Dec 31, 2019

@rust-highfive rust-highfive added the S-waiting-on-review Status: Awaiting review from the assignee but also interested parties. label Dec 31, 2019
Copy link
Member

@Mark-Simulacrum Mark-Simulacrum left a comment

Choose a reason for hiding this comment

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

r=me with comments addressed

.into_iter()
.map(Arc::new)
.collect::<Vec<_>>()
let (codegen_units, _) = time(tcx.sess, "partition and assert distinct symbols", || {
Copy link
Member

Choose a reason for hiding this comment

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

Why are we only putting these two in parallel? At least it looks like there's no dependency on codegen units until after we collect mono_items, shouldn't that also be a (third) parallel step here?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That step is pretty cheap so there isn't much point.

Copy link
Member

Choose a reason for hiding this comment

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

It seems like that's not really for us to decide (and rayon should hopefully deal with "pretty cheap" pretty well), but I'm not opposed to leaving it as is.

@@ -408,10 +406,12 @@ fn record_accesses<'tcx>(
mono_item.instantiation_mode(tcx) == InstantiationMode::LocalCopy
};

let accesses =
callees.into_iter().map(|mono_item| (*mono_item, is_inlining_candidate(mono_item)));
let accesses: SmallVec<[_; 128]> = callees
Copy link
Member

Choose a reason for hiding this comment

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

We should add a comment here about the deadlock between is_inlining_candidate and inlining_map, if I'm following correctly.

Copy link
Member

Choose a reason for hiding this comment

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

Yes, a deadlock definitely seems noteworthy.

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'm not sure what to note here other than don't call random code in locks =P

Copy link
Member

Choose a reason for hiding this comment

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

It is non-obvious to me at least when glancing at the code that there is a lock involved (and that is_inlining_candidate also takes it, if I'm recalling correctly). Explicitly noting that would be good.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Everything pretty much uses a lock unless you know otherwise. We can't have explicit notes on all function calls.

Copy link
Member

Choose a reason for hiding this comment

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

My main concern is that someone will drop the SmallVec here as an "optimization". I also feel like the argument about all functions potentially locking is a bit odd - if it were really true, then we'd be unable to review code well. I might even argue that a refactor which explicitly passes the lock in would be helpful here, if possible; it's hopefully rare that we have such unexpected locking.

@Zoxc
Copy link
Contributor Author

Zoxc commented Dec 31, 2019

I also think there might be some non-determinism that snuck in here. collect_crate_mono_items returns a list and set with a non-deterministic order, but I'm not sure they're used in a way where it would matter. cc @michaelwoerister

@bors
Copy link
Contributor

bors commented Jan 4, 2020

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

@Zoxc
Copy link
Contributor Author

Zoxc commented Jan 11, 2020

@bors r=Mark-Simulacrum

@bors
Copy link
Contributor

bors commented Jan 11, 2020

📌 Commit 4a64716 has been approved by Mark-Simulacrum

@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 Jan 11, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
bors added a commit that referenced this pull request Jan 11, 2020
Rollup of 9 pull requests

Successful merges:

 - #67000 (Promote references to constants instead of statics)
 - #67756 (Collector tweaks)
 - #67889 (Compile some CGUs in parallel at the start of codegen)
 - #67930 (Rename Result::as_deref_ok to as_deref)
 - #68018 (feature_gate: Remove `GateStrength`)
 - #68070 (clean up E0185 explanation)
 - #68072 (Fix ICE #68058)
 - #68114 (Don't require `allow_internal_unstable` unless `staged_api` is enabled.)
 - #68120 (Ban `...X` pats, harden tests, and improve diagnostics)

Failed merges:

r? @ghost
Centril added a commit to Centril/rust that referenced this pull request Jan 11, 2020
bors added a commit that referenced this pull request Jan 11, 2020
Rollup of 8 pull requests

Successful merges:

 - #67756 (Collector tweaks)
 - #67889 (Compile some CGUs in parallel at the start of codegen)
 - #67930 (Rename Result::as_deref_ok to as_deref)
 - #68018 (feature_gate: Remove `GateStrength`)
 - #68070 (clean up E0185 explanation)
 - #68072 (Fix ICE #68058)
 - #68114 (Don't require `allow_internal_unstable` unless `staged_api` is enabled.)
 - #68120 (Ban `...X` pats, harden tests, and improve diagnostics)

Failed merges:

r? @ghost
@bors bors merged commit 4a64716 into rust-lang:master Jan 11, 2020
@Zoxc Zoxc deleted the collector-tweaks branch January 11, 2020 19:11
@nnethercote nnethercote mentioned this pull request May 31, 2023
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.

5 participants