You would use one of those approaches: If you align and pad each slot there won't be any false sharing and the stream prefetcher can kick in if there's only one producer or consumer. If you use bijective hashing you…
Here's my widely used implementation of this approach in C++: https://github.com/rigtorp/MPMCQueue
That looks like a rewrite of my earlier work: https://rigtorp.se/ringbuffer/
Better to use the Gmail API to incrementally backup your mail: https://github.com/rigtorp/gmbackup
I have a tool that saves each mail as a single file using the Gmail API: https://github.com/rigtorp/gmbackup
Interesting, of course many computations can be expressed as a graph. In the case of the bipartite graph we perform belief propagation on to decode LDPC where is the optimization from the distributive property? The…
How is belief propagation used for decoding LDPC codes related to FFT?
I think it will be invalidated due to RFO when the reader reads the write index. Only when multiple readers reads the same cache line without any intervening write will the RFO heuristic be disabled.
It might also be better for performance since the two cores can RFO the buffer pointer cache lines from each other.
There might be an additional optimization in having the writer also cache it's write index on the cache line together with the read index cache. This way the writer would only do writes to the write index cache line.…
I have something similar but in C++: https://github.com/rigtorp/c2clat
You might need to add -fno-omit-frame-pointer to help ASAN unwind the stack.
You're incorrect, garbage collection would be the biggest problem for that use case. You have to be really careful even with your C/C++ code, warming up the branch predictor between packets etc, see my article for some…
The standard says that a thread must eventually terminate, do an atomic operation or do IO. So the while(lock.exchange(true)); loop is different. Also keep in mind that C++11 specifies std::mutex::lock() to have acquire…
There's even more discussion on the lock memory ordering on Stackoverflow: https://stackoverflow.com/questions/61299704/how-c-standard-... Taking a lock only needs to be an acquire operation and a compiler barrier for…
Yes that's right!
Well isn't that just a normal lock/mutex of the "lightweight" type (only enter kernel on contention)? You cannot use that in non-preemptible context.
Deploy to production :). You can use a model checker that understands C++11 memory model.
His rant only applies to preemptible threads. If you don't have preemptible threads spinlocks works great. The linux kernel uses them in non-preemptible contexts.
It's nonsense to do this when you can be preempted. But you can run one thread per core and avoid preemption. You can tune the linux kernel to avoid almost all preemption, due to TLB shootdowns etc:…
I now think it's actually this part of the standard that prevents it: http://eel.is/c++draft/intro.multithread#intro.progress-7 Basically a compiler can not optimize a non-deadlocking program into a potentially…
Yes this re-ordering can cause a deadlock. But it's not an allowed optimization to change a non-deadlocking program into a potentially deadlocking program, so this reordering can not happen.…
I think reitzensteinm was referring to the actual data inside the ring. There is a false sharing problem there particularly for the MPMC type ring buffer like disruptor. The solution is to pad each data slot in addition…
You can align and pad each ring buffer slot to the cache line size. Example https://github.com/rigtorp/MPMCQueue/blob/master/include/rig...
Ringbuffers and thread-per-core architecture is great for low latency transaction processing systems, like exchanges and trading systems. Sometimes you don't have time to do things perfectly and might use a spinlock…
You would use one of those approaches: If you align and pad each slot there won't be any false sharing and the stream prefetcher can kick in if there's only one producer or consumer. If you use bijective hashing you…
Here's my widely used implementation of this approach in C++: https://github.com/rigtorp/MPMCQueue
That looks like a rewrite of my earlier work: https://rigtorp.se/ringbuffer/
Better to use the Gmail API to incrementally backup your mail: https://github.com/rigtorp/gmbackup
I have a tool that saves each mail as a single file using the Gmail API: https://github.com/rigtorp/gmbackup
Interesting, of course many computations can be expressed as a graph. In the case of the bipartite graph we perform belief propagation on to decode LDPC where is the optimization from the distributive property? The…
How is belief propagation used for decoding LDPC codes related to FFT?
I think it will be invalidated due to RFO when the reader reads the write index. Only when multiple readers reads the same cache line without any intervening write will the RFO heuristic be disabled.
It might also be better for performance since the two cores can RFO the buffer pointer cache lines from each other.
There might be an additional optimization in having the writer also cache it's write index on the cache line together with the read index cache. This way the writer would only do writes to the write index cache line.…
I have something similar but in C++: https://github.com/rigtorp/c2clat
You might need to add -fno-omit-frame-pointer to help ASAN unwind the stack.
You're incorrect, garbage collection would be the biggest problem for that use case. You have to be really careful even with your C/C++ code, warming up the branch predictor between packets etc, see my article for some…
The standard says that a thread must eventually terminate, do an atomic operation or do IO. So the while(lock.exchange(true)); loop is different. Also keep in mind that C++11 specifies std::mutex::lock() to have acquire…
There's even more discussion on the lock memory ordering on Stackoverflow: https://stackoverflow.com/questions/61299704/how-c-standard-... Taking a lock only needs to be an acquire operation and a compiler barrier for…
Yes that's right!
Well isn't that just a normal lock/mutex of the "lightweight" type (only enter kernel on contention)? You cannot use that in non-preemptible context.
Deploy to production :). You can use a model checker that understands C++11 memory model.
His rant only applies to preemptible threads. If you don't have preemptible threads spinlocks works great. The linux kernel uses them in non-preemptible contexts.
It's nonsense to do this when you can be preempted. But you can run one thread per core and avoid preemption. You can tune the linux kernel to avoid almost all preemption, due to TLB shootdowns etc:…
I now think it's actually this part of the standard that prevents it: http://eel.is/c++draft/intro.multithread#intro.progress-7 Basically a compiler can not optimize a non-deadlocking program into a potentially…
Yes this re-ordering can cause a deadlock. But it's not an allowed optimization to change a non-deadlocking program into a potentially deadlocking program, so this reordering can not happen.…
I think reitzensteinm was referring to the actual data inside the ring. There is a false sharing problem there particularly for the MPMC type ring buffer like disruptor. The solution is to pad each data slot in addition…
You can align and pad each ring buffer slot to the cache line size. Example https://github.com/rigtorp/MPMCQueue/blob/master/include/rig...
Ringbuffers and thread-per-core architecture is great for low latency transaction processing systems, like exchanges and trading systems. Sometimes you don't have time to do things perfectly and might use a spinlock…