
Understanding Hardware Transactional Memory [pdf] - dmit
https://www.azul.com/files/Understanding-HW-Transactional-Memory-QCon-London-3.16-Gil-Tene.pdf
======
Animats
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
tl;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/se...](https://www.cs.umd.edu/class/sum2003/cmsc311/Notes/Memory/set.html)

This presentation is also a lot easier to understand when watching the whole
talk: [http://www.infoq.com/presentations/hardware-transactional-
me...](http://www.infoq.com/presentations/hardware-transactional-memory)

------
sievebrain
What this presentation doesn't mention is that HotSpot supports automatic
conversion of synchronised blocks to TSX transactions already. So if you run
the latest HotSpots on the latest Intel chips (note: TSX was disabled for some
Haswells) then you are already benefiting from this!

What people found, if I recall correctly, was that a lot of popular software
doesn't benefit much because it wasn't written to reduce data contention, and
servers especially often contend on statistics and metrics counters. But the
slides show ways to avoid that. Also, the most popular software was often
already well optimised to reduce lock contention.

------
bajsejohannes
Here's the talk: [http://www.infoq.com/presentations/hardware-transactional-
me...](http://www.infoq.com/presentations/hardware-transactional-memory)

~~~
alblue
I interviewed Gil Tene at QCon London 2016 about what Hardware Transactional
Memory is and why it will be important. The interview has now been posted on-
line:

[http://www.infoq.com/interviews/tene-hardware-
transactional-...](http://www.infoq.com/interviews/tene-hardware-
transactional-memory)

