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

Remove BodyAndCache #71044

Merged
merged 5 commits into from
Apr 23, 2020
Merged

Conversation

ecstatic-morse
Copy link
Contributor

@ecstatic-morse ecstatic-morse commented Apr 11, 2020

...returning to the original approach using interior mutability within Body. This simplifies the API at the cost of some uncontended mutex locks when the parallel compiler is enabled.

The current API requires you to either have a mutable reference to Body (&mut BodyAndCache), or to compute the predecessor graph ahead of time by creating a ReadOnlyBodyAndCache. This is not a good fit for, e.g., the dataflow framework, which

  1. does not mutate the MIR
  2. only sometimes needs the predecessor graph (for backward dataflow problems)

@rust-highfive
Copy link
Collaborator

r? @matthewjasper

(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 Apr 11, 2020
@ecstatic-morse
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 Apr 11, 2020

⌛ Trying commit b117f26adbb92bd2114aa7438a1558c673060d5c with merge 0f456c9e7ee3bfbf52e3ad1a857d8c051754aa9b...

@ecstatic-morse
Copy link
Contributor Author

@bors try-

@ecstatic-morse ecstatic-morse force-pushed the body-predecessor-cache branch from b117f26 to 92e2549 Compare April 11, 2020 21:42
@ecstatic-morse
Copy link
Contributor Author

@bors try

@bors
Copy link
Contributor

bors commented Apr 11, 2020

⌛ Trying commit 92e25499c622d84b35b7c66c0e0ee08253f459b5 with merge 198316ac3da8706e1bc304042111f0e4dc0b9e43...

@bors
Copy link
Contributor

bors commented Apr 12, 2020

☀️ Try build successful - checks-azure
Build commit: 198316ac3da8706e1bc304042111f0e4dc0b9e43 (198316ac3da8706e1bc304042111f0e4dc0b9e43)

@rust-timer
Copy link
Collaborator

Queued 198316ac3da8706e1bc304042111f0e4dc0b9e43 with parent e82734e, future comparison URL.

@rust-timer
Copy link
Collaborator

Finished benchmarking try commit 198316ac3da8706e1bc304042111f0e4dc0b9e43, comparison URL.

@ecstatic-morse ecstatic-morse force-pushed the body-predecessor-cache branch from 92e2549 to 7c19a98 Compare April 12, 2020 17:57
@ecstatic-morse
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 Apr 12, 2020

⌛ Trying commit 7c19a989c3531b977b09780636a3e287e3562abc with merge abfaf6666e74e407628239bae61a008f6c8c3457...

@bors
Copy link
Contributor

bors commented Apr 12, 2020

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

@rust-timer
Copy link
Collaborator

Queued abfaf6666e74e407628239bae61a008f6c8c3457 with parent 4d1fbac, future comparison URL.

@ecstatic-morse
Copy link
Contributor Author

Will try another perf run after #71208.

@ecstatic-morse ecstatic-morse force-pushed the body-predecessor-cache branch 2 times, most recently from fd83ac3 to 84d67f9 Compare April 19, 2020 21:02
@ecstatic-morse
Copy link
Contributor Author

#71208 had no effect on performance for master, but I'm going to try this PR with calls to emit_unit inlined. I guess I could also try making the encode/decode bodies do absolutely nothing. I will say that the larger regressions are on small/contrived benchmarks. Presumably metadata encoding is a bigger percentage of total instructions in those cases? I think it would be acceptable to land this with the current performance, but this really should be no change.

@ecstatic-morse
Copy link
Contributor Author

@bors try @rust-timer queue

...with a single one to `predecessors`. `predecessors_for` requires
taking the lock/incrementing the `RefCell` once each call.
@ecstatic-morse ecstatic-morse force-pushed the body-predecessor-cache branch from 84d67f9 to 4e7469e Compare April 22, 2020 17:01
@ecstatic-morse
Copy link
Contributor Author

Failed spuriously while installing awscli.

@bors r=oli-obk

@bors
Copy link
Contributor

bors commented Apr 22, 2020

📌 Commit 4e7469e has been approved by oli-obk

@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 22, 2020
@bors
Copy link
Contributor

bors commented Apr 22, 2020

⌛ Testing commit 4e7469e with merge db9b05a...

@bors
Copy link
Contributor

bors commented Apr 23, 2020

☀️ Test successful - checks-azure
Approved by: oli-obk
Pushing db9b05a to master...

@bors bors added the merged-by-bors This PR was explicitly merged by bors. label Apr 23, 2020
@bors bors merged commit db9b05a into rust-lang:master Apr 23, 2020
@rust-highfive
Copy link
Collaborator

📣 Toolstate changed by #71044!

Tested on commit db9b05a.
Direct link to PR: #71044

💔 clippy-driver on windows: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).
💔 clippy-driver on linux: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).

rust-highfive added a commit to rust-lang-nursery/rust-toolstate that referenced this pull request Apr 23, 2020
Tested on commit rust-lang/rust@db9b05a.
Direct link to PR: <rust-lang/rust#71044>

💔 clippy-driver on windows: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).
💔 clippy-driver on linux: test-pass → build-fail (cc @mcarton @oli-obk @Manishearth @flip1995 @yaahc @phansch @llogiq).
bors added a commit to rust-lang/rust-clippy that referenced this pull request Apr 23, 2020
Rustup "Remove `BodyAndCache`"

cc rust-lang/rust#71044
changelog: none
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 24, 2020
…he-arc, r=nikomatsakis

Don't hold the predecessor cache lock longer than necessary

rust-lang#71044 returns a `LockGuard` with the predecessor cache to callers of `Body::predecessors`. As a result, the lock around the predecessor cache could be held for an arbitrarily long time. This PR uses reference counting for ownership of the predecessor cache, meaning the lock is only ever held within `PredecessorCache::compute`. Checking this API for potential sources of deadlock is much easier now, since we no longer have to consider its consumers, only its internals.

This required removing `predecessors_for`, since there is no equivalent to `LockGuard::map` for `Arc` and `Rc`. I believe this could be emulated with `owning_ref::{Arc,Rc}Ref`, but I don't think it's necessary. Also, we continue to return an opaque type from `Body::predecessors` with the lifetime of the `Body`, not `'static`.

This depends on rust-lang#71044. Only the last two commits are new.

r? @nikomatsakis
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 25, 2020
…he-arc, r=nikomatsakis

Don't hold the predecessor cache lock longer than necessary

rust-lang#71044 returns a `LockGuard` with the predecessor cache to callers of `Body::predecessors`. As a result, the lock around the predecessor cache could be held for an arbitrarily long time. This PR uses reference counting for ownership of the predecessor cache, meaning the lock is only ever held within `PredecessorCache::compute`. Checking this API for potential sources of deadlock is much easier now, since we no longer have to consider its consumers, only its internals.

This required removing `predecessors_for`, since there is no equivalent to `LockGuard::map` for `Arc` and `Rc`. I believe this could be emulated with `owning_ref::{Arc,Rc}Ref`, but I don't think it's necessary. Also, we continue to return an opaque type from `Body::predecessors` with the lifetime of the `Body`, not `'static`.

This depends on rust-lang#71044. Only the last two commits are new.

r? @nikomatsakis
Dylan-DPC-zz pushed a commit to Dylan-DPC-zz/rust that referenced this pull request Apr 25, 2020
…he-arc, r=nikomatsakis

Don't hold the predecessor cache lock longer than necessary

rust-lang#71044 returns a `LockGuard` with the predecessor cache to callers of `Body::predecessors`. As a result, the lock around the predecessor cache could be held for an arbitrarily long time. This PR uses reference counting for ownership of the predecessor cache, meaning the lock is only ever held within `PredecessorCache::compute`. Checking this API for potential sources of deadlock is much easier now, since we no longer have to consider its consumers, only its internals.

This required removing `predecessors_for`, since there is no equivalent to `LockGuard::map` for `Arc` and `Rc`. I believe this could be emulated with `owning_ref::{Arc,Rc}Ref`, but I don't think it's necessary. Also, we continue to return an opaque type from `Body::predecessors` with the lifetime of the `Body`, not `'static`.

This depends on rust-lang#71044. Only the last two commits are new.

r? @nikomatsakis
@ecstatic-morse ecstatic-morse deleted the body-predecessor-cache branch October 6, 2020 01:42
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.

7 participants