-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Don't hold the predecessor cache lock longer than necessary #71392
Don't hold the predecessor cache lock longer than necessary #71392
Conversation
☔ The latest upstream changes (presumably #71323) made this pull request unmergeable. Please resolve the merge conflicts. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
r=me on the last two commits, thanks @ecstatic-morse !
@bors delegate=ecstatic-morse |
✌️ @ecstatic-morse can now approve this pull request |
There is no `Arc::map` equivalent to `LockGuard::map`
...instead of a `LockGuard` which means the lock is held for longer than necessary.
00ac196
to
59c7460
Compare
Rebased and restricted visibility of the @bors r=nikomatsakis |
📌 Commit 34dfbc3 has been approved by |
…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
…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
Rollup of 5 pull requests Successful merges: - rust-lang#70043 (Add all remaining `DefKind`s.) - rust-lang#71140 ([breaking change] Disallow statics initializing themselves) - rust-lang#71392 (Don't hold the predecessor cache lock longer than necessary) - rust-lang#71541 (Add regression test for rust-lang#26376) - rust-lang#71554 (Replace thread_local with generator resume arguments in box_region.) Failed merges: r? @ghost
#71044 returns a
LockGuard
with the predecessor cache to callers ofBody::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 withinPredecessorCache::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 toLockGuard::map
forArc
andRc
. I believe this could be emulated withowning_ref::{Arc,Rc}Ref
, but I don't think it's necessary. Also, we continue to return an opaque type fromBody::predecessors
with the lifetime of theBody
, not'static
.This depends on #71044. Only the last two commits are new.
r? @nikomatsakis