Hacker News new | past | comments | ask | show | jobs | submit login
Understanding Hardware Transactional Memory [pdf] (azul.com)
34 points by dmit on Apr 3, 2016 | hide | past | favorite | 5 comments



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.


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...

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


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.



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-...




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: