I understand that I can reduce the few ms latency when acquiring a std::mutex, and perhaps this is valuable for high frequency trading, but I am not sure if this will improve performance in a palpable manner.
Does anybody have any good uses cases for lock-free programming where the goal is to scale beyond a single producer-consumer scheme?
Locks were not available, so it was simply not an option. So they instead chose a lockless "ethernet with memory space collisions" analog to normal "ethernet with wire timing collisions"
The implementation was to allow concurrent overlapping readers and writers into shared memory, but reading was done backward through memory, and writing was done forward. Readers could thus tell (checksum) if their read got corrupted by an overlapping write, and they could cancel and reinitiate. As long as there are not a large number of collisions, it's a very fast system with no waiting. Again, imagine the intensity and criticality of Facebook object sharing; on a human scale there might be a lot of concurrency and benefit to caching, but at processor speed there will not be much read/write contention.
There was more to the scheme which I don't exactly remember. For example, you can see that a writer can also tell if the write was corrupted by a concurrent write by following with a reread, but that's not what they did. I think there were two pools of shared storage, memory chunks and tables of handles to chunks, and the writers coordinated their lockless shared writes via the table of handles to the chunks using the same forward/backward contention (or really corruption) detection.
http://lmax-exchange.github.io/disruptor/files/Disruptor-1.0...
I posted it a while ago, but it didn't get any traction. I use it a system with multiple consumers, I wouldn't call it HFT but its as close as most trading systems will get:)
We use it to pass quotes to each algo that requires it and to pass orders from high level algos down to an execution layer that determines how to send each algo's order to market.
I'd probably want to go wait-free if I was writing software for a Mars lander, but lock-free is good enough for consumer audio tasks, where mutexes generally aren't.