Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upCAS is wrong (no compare-and-swap) #116
Comments
ticki
changed the title
CAS isn't compare-and-swap.
CAS is wrong.
Mar 8, 2017
ticki
changed the title
CAS is wrong.
CAS is wrong (no compare-and-swap)
Mar 8, 2017
ticki
added a commit
to ticki/crossbeam
that referenced
this issue
Mar 8, 2017
ticki
referenced this issue
Mar 8, 2017
Closed
Add compare-and-swap and rename all the `cas_` prefixed methods. #118
This comment has been minimized.
This comment has been minimized.
|
Implemented in #118 |
ticki
added a commit
to ticki/crossbeam
that referenced
this issue
Mar 8, 2017
ticki
added a commit
to ticki/crossbeam
that referenced
this issue
Mar 8, 2017
This comment has been minimized.
This comment has been minimized.
|
I see #118 was closed. What's the status on this? I just started converting from raw pointers to this library for my lock-free log-structured persistent b-link tree and hitting this was kind of a facepalm... |
This comment has been minimized.
This comment has been minimized.
|
We have a new API (designed in this RFC) in the crossbeam-epoch repository, which is currently in development, but not yet in a usable state. We'll have a new, better epoch-based GC within the next month or so. |
This comment has been minimized.
This comment has been minimized.
|
@spacejam If I understand correctly, you're basically implementing Microsoft's Deuteronomy in Rust? Looks very very cool! :) I have a few questions:
|
This comment has been minimized.
This comment has been minimized.
|
@stjepang thanks! yes, the design is heavily inspired by the llama / bw tree / deuteronomy papers.
|
This comment has been minimized.
This comment has been minimized.
|
I'll dig into that RFC! Thanks for the info! |
This comment has been minimized.
This comment has been minimized.
|
@stjepang |
This comment has been minimized.
This comment has been minimized.
There is, but it's in my local branch. I'll try to whip up something this weekend so you can test it. |
This comment has been minimized.
This comment has been minimized.
|
@stjepang awesome! my goal is to have epoch-style management in rsdb in the next week or so, so that I can shift efforts to performance and reliability for a beta release by the end of the month. Those efforts will involve burning a lot of CPU cyles on exploring the thread-interleaving space, so maybe I'll get lucky and suss-out some bugs in this implementation as well. |
ticki commentedMar 8, 2017
•
edited
Atomic::<T>::cas()has signatureBut this isn't CAS in the classical sense. In fact, it makes certain things impossible to do. In particular, you don't get the value which didn't match. It acts more as "compare-and-set" rather than "compare-and-swap" (which is what the short form "CAS" tend to be used for).
I propose a non-breaking change (I do so because I think this problem is a major problem that needs to be addressed), which renames
cas→compare_and_setcas_and_ref→compare_and_set_refcas_shared→compare_and_set_sharedAnd uses the old names to alias these, but mark them with
#[deprecated]and changed their doc comments to "Deprecated. Do not use." (kind of like what I did in chashmap).Futhermore, the crux is to introduce a new method,
compare_and_swap, with signatureAs for the semantics, this method compares
selfagainstold, and if it matches, it setsselftonewand returnsOk(()). If the two don't match,Err(val)is returned, wherevalis the valueselfinstead holds.The change is pretty basic, but is it something of interest?
ping @aturon @alexcrichton /