Post

ЈΘСΞR
ЈΘСΞR@jocerfranquiz·
@Adriksh First time hearing about this. Thank you. Bookmarked already
English
1
0
2
5.2K
James Seymour 🇺🇸
James Seymour 🇺🇸@realJSeymour·
@Adriksh I once implemented a ring buffer for something, no longer recall what. Worked a treat 🙂
English
1
0
1
3K
Marc
Marc@mrousavy·
@Adriksh super interesting read, and nice note on the atomics memory order.
English
0
0
2
1K
Raindrop
Raindrop@qwqbebe·
@Adriksh and what's funny is that this is exactly what a ring buffer involving copies looks like. it's not zero copy
English
1
0
7
510
Sharon Besser
Sharon Besser@sbesser·
@Adriksh Thanks 4 sharing. U explain complicated concepts well. My days as a code writer have ended many years ago and while I believe the "new generation" is far more talented l, capable, & has tools we could only dream of, they lack basic understanding that would make them 10x better.
English
0
1
4
784
Kevin Milczewski
Kevin Milczewski@KevinMilczewski·
@Adriksh "no memcpy" -> writes a bytewise memory copy manually and stores the whole data in the ring. The way to do this right is to pair it with an object pool and pass the pointers through the ring. That is zero copy. Of course your object pool is likely to use the same structure.
English
0
0
4
188
Manjuk
Manjuk@ManjuktheGeek·
@Adriksh Small but critical nit: your & (BUFFER_SIZE - 1) wraparound only works if BUFFER_SIZE is a power of two. Otherwise it’s not a modulo and the ring buffer will break.
English
1
0
4
172
mikasa
mikasa@10xMikasa·
@Adriksh Wow i was looking for this
English
0
0
3
949
Toughware Guy
Toughware Guy@__toughware__·
@Adriksh Nice refresher! Looking forward to a similar write-up on MPMC implementation using CAS
English
0
0
3
640
Francesco Nigro
Francesco Nigro@forked_franz·
@Adriksh If the slot content fits into a single world you can use it both to check wrapping/emptiness in offer/poll - enabling interesting optimization like looking ahead by N for emptiness. That distribute the contention vs the producer/consume sequences
English
0
0
2
989
Alessandro Morelli
Alessandro Morelli@AlexMore1987·
@Adriksh An important point is that the acquire loads let previous instructions be reordered after it. This means that tail can be loaded after head, but not after the following instructions because of data dependency. This guarantees correctness.
English
0
0
2
721
Mohit
Mohit@0xhashqueu·
@Adriksh Nice, i add mutex and call it a day Seems like this will be an interesting read Keep up these articles
English
0
0
2
714
SomeOldGuy
SomeOldGuy@old_some69688·
@Adriksh Been using ring buffers since my early days writing async communications code in the 80's.
English
0
0
1
660
Karol Gasiński
Karol Gasiński@karolgasinski·
@Adriksh In push I think you’re still missing std::atomic_thread_fence(std::memory_order_release); after writing data to ring buffer, but before updating atomic. You need to flush that data to be visible to other thread, otherwise only head and tail are guaranteed to be visible.
English
0
0
1
247
Mohit
Mohit@0xhashqueu·
@Adriksh more bookmarks than likes :)
English
0
0
1
225
Nitish kumar
Nitish kumar@NitishCseKiit·
@Adriksh Why don't we use memcpy instead of running for loop ?
English
0
0
0
582
geniusvczh
geniusvczh@geniusvczh·
@Adriksh Thread safe with two parallel pushes? And why?
English
3
0
0
2K
jrbergsten
jrbergsten@jrbergsten·
@Adriksh NVMe drive host interface works this way.
English
0
0
0
69
Paylaş