3 ms·
This is compare-and-swap, the next generation. It's going to be useful. It's a bit vague about what happens when you get contention and a transaction rejects.
by Animats 11y ago
This is compare-and-swap, the next generation. It's going to be useful.
It's a bit vague about what happens when you get contention and a transaction rejects. Try again immediately? Spin and try again? Wait and try again? Wait and try again with exponential backoff? All of the above, in sequence?
There are a few spots in Go where the concurrency isn't airtight, such as shared maps. This allows fixing that problem.
- bajsejohannes 11y agotl;dr: You need to fall back to "the old way" (e.g. locks, compare-and-swap, etc). Your transaction might get rejected no matter how many retries you do because the memory you touch doesn't all fit in CPU cache. CPU Cache mapping is made complicated by things like 8 way set associative (slide 17) which means something that used to work with transactions might not work if memory layout changes. Therefore, if you get a rejection, you might want to try again a couple of times, but eventually you'll need to do it some other way. For an explanation of set associative mapping, see https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/set.html https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/se... This presentation is also a lot easier to understand when watching the whole talk: http://www.infoq.com/presentations/hardware-transactional-memory http://www.infoq.com/presentations/hardware-transactional-me...