3 ms·
I am working on a C version of the disruptor ringbuffer it is very simple and I need to verify it so it's probably not ready for others but it might be interest
by samsquire 3y ago
I am working on a C version of the disruptor ringbuffer it is very simple and I need to verify it so it's probably not ready for others but it might be interesting. Aligning by 128 bytes has dropped latency and stopped false sharing.
I have gotten latencies to 50 nanoseconds and up.
disruptor-multi.c(SPMC) and disruptor-multi-producer.c (MPSC)
https://GitHub.com/samsquire/assembly https://GitHub.com/samsquire/assembly
I am trying to work out how to support multiple producers and multiple readers (MPMC) at low latency that's what I'm literally working on today.
The MPSC and SPMC seem to be working at low latencies.
I am hoping to apply actor model to the ringbuffer for communication.
I'm also working on nonblocking lock free barrier. This has latency as low as 42 nanoseconds and up.
- cplusplusfellow 3y agoDo you think it’s possible to obtain this performance with Rust? I’ve been down the path you’re on a few times and I love the pursuit. Have built my own over the years about 4 times. Hardware was much slower in those days so my lower barrier was 650ns. Things got worse appreciably as a function of the number of producers I found. Some of my most sleepless nights. The funnest nights.
- topbanana 3y agostd::collections::vec_deque is implemented as a growable ring buffer so you might like to start there https://doc.rust-lang.org/std/collections/vec_deque/index.html https://doc.rust-lang.org/std/collections/vec_deque/index.ht...
- samsquire 3y agoHow many producers and how many consumers is that 650 nanoseconds? I have pinned threads to even numbered cores with pthread_setaffinity_np and that seems to have evened out the MPMC ringbuffer - 2 producers 2 consumers to under 400 nanoseconds, usually under 1000 nanoseconds. I think hyperthreading causes problems. EDIT: Would you like to chat about this? I would like to! My email is in my profile.