-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Waker::will_wake: Compare vtable address instead of its content #119863
Conversation
Optimize will_wake implementation by comparing vtable address instead of its content. The existing best practice to avoid false negatives from will_wake is to define a waker vtable as a static item. That approach continues to works with the new implementation. While this potentially changes the observable behaviour, the function is documented to work on a best-effort basis. The PartialEq impl for RawWaker remains as it was.
r? @thomcc (rustbot has picked a reviewer for you, use r? to override) |
I'm going to be away for a few months, so I'm rerolling my PRs so that folks don't have to wait for me. Sorry/thanks. r? libs |
@bors r+ |
☀️ Test successful - checks-actions |
Finished benchmarking commit (62fb0db): comparison URL. Overall result: ❌ regressions - no action needed@rustbot label: -perf-regression Instruction countThis is a highly reliable metric that was used to determine the overall result at the top of this comment.
Max RSS (memory usage)ResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResultsThis is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 637.562s -> 638.252s (0.11%) |
Preserve same vtable pointer when cloning raw waker, to fix Waker::will_wake Fixes rust-lang#121600. As `@jkarneges` identified in rust-lang#121600 (comment), the issue is two different const promotions produce two statics at different addresses, which may or may not later be deduplicated by the linker (in this case not). Prior to rust-lang#119863, the content of the statics was compared, and they were equal. After, the address of the statics are compared and they are not equal. It is documented that `will_wake` _"works on a best-effort basis, and may return false even when the Wakers would awaken the same task"_ so this PR fixes a quality-of-implementation issue, not a correctness issue.
Rollup merge of rust-lang#121622 - dtolnay:wake, r=cuviper Preserve same vtable pointer when cloning raw waker, to fix Waker::will_wake Fixes rust-lang#121600. As `@jkarneges` identified in rust-lang#121600 (comment), the issue is two different const promotions produce two statics at different addresses, which may or may not later be deduplicated by the linker (in this case not). Prior to rust-lang#119863, the content of the statics was compared, and they were equal. After, the address of the statics are compared and they are not equal. It is documented that `will_wake` _"works on a best-effort basis, and may return false even when the Wakers would awaken the same task"_ so this PR fixes a quality-of-implementation issue, not a correctness issue.
We used `will_wake` in correctness checks to make sure we don't hang the future/stream forever if a wrong waker is used, but the contract for this function is best-effort and it started generating more and more false positives. The recent one, found by @aleiserson, is inside rust-lang (rust-lang/rust#119863), so it is very hard to get around. We don't have a good replacement for this check unless we implement our own waker, but it is probably too much for now
We used `will_wake` in correctness checks to make sure we don't hang the future/stream forever if a wrong waker is used, but the contract for this function is best-effort and it started generating more and more false positives. The recent one, found by @aleiserson, is inside rust-lang (rust-lang/rust#119863), so it is very hard to get around. We don't have a good replacement for this check unless we implement our own waker, but it is probably too much for now
…cuviper make LocalWaker::will_wake consistent with Waker::will_wake This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
…cuviper make LocalWaker::will_wake consistent with Waker::will_wake This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
Rollup merge of rust-lang#128882 - RalfJung:local-waker-will-wake, r=cuviper make LocalWaker::will_wake consistent with Waker::will_wake This mirrors rust-lang#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang#118960).
make LocalWaker::will_wake consistent with Waker::will_wake This mirrors rust-lang/rust#119863 for `LocalWaker`. Looks like that got missed in the initial `LocalWaker` PR (rust-lang/rust#118960).
Optimize will_wake implementation by comparing vtable address instead of its content.
The existing best practice to avoid false negatives from will_wake is to define a waker vtable as a static item. That approach continues to works with the new implementation.
While this potentially changes the observable behaviour, the function is documented to work on a best-effort basis. The PartialEq impl for RawWaker remains as it was.