Uh oh!
There was an error while loading. Please reload this page.
Simplify AtomicBool::fetch_nand - #40563
Conversation
This should also be faster
rust-highfive
commented
Mar 16, 2017
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @aturon (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. |
alexcrichton
commented
Mar 16, 2017
Looks like tests are failing? |
nagisa
commented
Mar 16, 2017
I think you can simply |
mstewartgallus
commented
Mar 16, 2017
@nagis That is true. However, a swap implies a write all the time instead while a compare and swap does not which can be faster sometimes. In any case the bug was in the |
alexcrichton
commented
Mar 20, 2017
The lack of a |
mstewartgallus
commented
Mar 20, 2017
@alexcrichton That's deliberate. !(x && false) = true. If x is true and not false then no write needs to happen which is good for the cache. |
| // !(false && true) == true | ||
| // !(x && true) == !x | ||
| // !(x && false) == true |
There was a problem hiding this comment.
I would use & instead of && in these, seems clearer.
| // !(x && true) == !x | ||
| // !(x && false) == true | ||
| if val { | ||
| return self.fetch_xor(true, order); |
mstewartgallus
commented
Mar 21, 2017
This is odd https://travis-ci.org/rust-lang/rust/jobs/213176849 I can't view what happened here. |
nagisa
commented
Mar 21, 2017
via email
To me this all seems correct. I still think atomoc_swap would be better in
a sense that it's easier to see it's obviously correct unlike he CAS but
either way seems correct to me. …On Mar 21, 2017 05:54, "Steven Stewart-Gallus" ***@***.***> wrote:
This is odd https://travis-ci.org/rust-lang/rust/jobs/213176849 I can't
view what happened here.
—
You are receiving this because you commented.
Reply to this email directly, view it on GitHub
<#40563 (comment)>, or mute
the thread
<https://github.com/notifications/unsubscribe-auth/AApc0lTDx9MPxut9YjQeAv9u25dJL9L3ks5rn0n2gaJpZM4Metst>
.
|
@sstewartgallus Only one configuration is supposed to run on a PR, but the only way to do that in travis is to finish immediately for non-PR configurations. But macOS ones sometimes even fail at that. |
alexcrichton
commented
Mar 21, 2017
Do you have benchmarks for this as well to justify this change? |
mstewartgallus
commented
Mar 21, 2017
@alexcrichton Fair enough. However, as this is in libcore I can't easily use std::threads for benchmarking purposes can I? |
eddyb
commented
Mar 21, 2017
@sstewartgallus You can write your own standalone benchmark. |
Benchmark: source Pretty good imprevements! :) Let's just get rid of that unnecessary |
Let's close this stale PR, as we've pushed the changes forward through a newer PR. |
…r=nagisa Optimize AtomicBool::fetch_nand This is an attempt to push the PR rust-lang#40563 to completion. Benchmark: [source](https://gist.github.com/stjepang/023f5025623f5474184f9f4dfd6379ae) Improvement: ``` name old_ ns/iter new_ce_ ns/iter diff ns/iter diff % 1t 146,440 89,904 -56,536 -38.61% 2t 561,456 316,835 -244,621 -43.57% 4t 2,822,821 1,005,424 -1,817,397 -64.38% ``` r? @eddyb cc @alexcrichton@nagisa
…r=nagisa Optimize AtomicBool::fetch_nand This is an attempt to push the PR rust-lang#40563 to completion. Benchmark: [source](https://gist.github.com/stjepang/023f5025623f5474184f9f4dfd6379ae) Improvement: ``` name old_ ns/iter new_ce_ ns/iter diff ns/iter diff % 1t 146,440 89,904 -56,536 -38.61% 2t 561,456 316,835 -244,621 -43.57% 4t 2,822,821 1,005,424 -1,817,397 -64.38% ``` r? @eddyb cc @alexcrichton@nagisa
This should also be faster.
This code avoids storing in cases where there would not be a change.