Bigger issue is that the reader needs to busy poll, consuming 100% CPU time on one CPU core. Maybe energy consumption could be reduced by using monitor/mwait - not sure if it's possible from user mode or only in kernel.
Another issues in this implementation is use of compare-and-swap. For this purpose, fetch-and-add (LOCK XADD on x86) would be more efficient. Multiple writer contention is much worse with CAS.
Record size is also fixed, you can't have multiple different message sizes.
Overhead per message is 12 bytes, two ints that can be either 0 or 1 and an int called Metadata. Seeing there's commit and rollback fields, both 1 byte, 2 byte overhead for commit and rollback should have been enough. You're going to get false sharing whether it's an int or a byte.
Why, out of interest?
Fetch-and-add is totally wait-free, much better upper bound. It always succeeds on first try.
https://github.com/jberryman/unagi-chan
Interested to check out your work! I'd love to be able to extend my library to support IPC in some way.
It is often about latency not just throughput. Although sometimes they go hand in hand. For example you can achieve pretty high throughput if you take the whole network stack outside the kernel and talk directly to the network card.
http://www.intel.com/content/dam/www/public/us/en/documents/...
But I've seen this spin polling done when latency needed to be optimized.
A reason inter-process communication is interesting, especially in java, is that there is a reasonably common pattern of isolating low latency code in 1 JVM and less sensitive code in another to prevent system wide pauses from bleeding across.
This can be super painful for development iteration though so one thing that is interesting about this library is that it seems to make that configuration time concern.
I realize that there probably are use cases out there that justify this, but I have not been tasked with one...
Polling is not necessarily evil or wasteful.