3 ms·
Before using HTM, I encourage the OP to use lockfree structures and atomics. Transactional memory is absolutely not free and certainly not a silver bullet. Ad
by shin_lao 13y ago
Before using HTM, I encourage the OP to use lockfree structures and atomics.
Transactional memory is absolutely not free and certainly not a silver bullet.
Additionally, without proper compiler support it's going to be very hard to use it properly.
- joe_the_user 13y agoCan you go into more detail on this?
- colanderman 13y ago> Transactional memory is absolutely not free Can you please compare in your experience, the performance of HTM with lock-free structures? My experience is that lock-free structures are rather slow, and my understanding of TSX is that it is almost free. > without proper compiler support it's going to be very hard to use it properly. They're using Intel's HLE, which requires very simple library support, which is already included in recent versions glibc.
- shin_lao 13y agoLock free structures are as slow as your memory allocation scheme (nota bene: I've designed several lockfree structures). If you're clever about how you use them, it can be a big win. HLE isn't really HTM, but it's a first step.
- colanderman 13y agoLock free structures are as slow as your memory allocation scheme I've found they're an order of magnitude slower than your architecture's atomics, and mostly exacerbated by the memory fencing required. Though, the structures I've used (queue & stack) didn't require any memory allocation on the fly. HLE isn't really HTM, but it's a first step. I know; my post should be read in the broader context of Intel's TSX (which includes their RTM instructions).
- shin_lao 13y agoWhich lock-free structure have you been using and for what purpose?
- colanderman 13y agoMichael & Scott, "Simple, Fast, and Practical Non-Blocking and Blocking Concurrent Queue Algorithms", which I understand to be fairly standard, as well as the "textbook" lock-free stack algorithm (dunno who invented it, I re-"invented" it myself and then confirmed it was identical to that given in The Art of Multiprocessor Programming). Use case for the queue is message-passing. Use case for the stack is as the allocator for the queue.
- shin_lao 13y agoWhich language? C? You did your own implementation? Sounds like you used the wrong stuff.
- colanderman 13y agoYes, C, my own implementation. What is the "right" stuff for low-latency high-contention message passing?
- shin_lao 13y agoWell, if you were coding in C++ I would say "have a look at TBB". The thing is, text book implementations generally lack all the platform dependant details to make it efficient.
- jamesaguilar 13y agoTo be fair, contended atomics aren't free either, especially if you're on the wrong NUMA node. Sharing is rarely free, so try not to share.
- shin_lao 13y agoExactly. Sharing is free for reading only... The minute you write, the laws of physics are there to annoy you.
- signa11 13y agohere is a relevant acm article from quite some time back on the topic: http://queue.acm.org/detail.cfm?id=1454466 http://queue.acm.org/detail.cfm?id=1454466