r/cpp • • Mar 24 '26

Optimizing a Lock-Free Ring Buffer

https://david.alvarezrosa.com/posts/optimizing-a-lock-free-ring-buffer/
106 Upvotes

58 comments sorted by

View all comments

Show parent comment

-2

u/rzhxd Mar 24 '26

It's not my fault that Reddit doesn't collapse long comments. For line numbers, you can copy it to your notepad. I know it works because it's literally a block of code from my machine that's not even committed to the repository yet. Use your brain, please.

6

u/HommeMusical Mar 24 '26

Writing lock-free code that works under all circumstances - or even works provably 100% reliably on one application - is extremely tricky.

What in this code keeps consistency under concurrent access? It's very unclear that anything is doing that.

Why do you think you have solved this problem? You don't say.

It's not my fault that Reddit doesn't collapse long comments.

It is your fault for knowing that and spamming us anyway.

I know it works because it's literally a block of code from my machine that's not even committed to the repository yet.

No, that's not what "knowing something works" means.

Use your brain, please.

I mean, this pair of sentences really does speak for itself.

3

u/SkoomaDentist Antimodern C++, Embedded, Audio Mar 25 '26

Writing lock-free code that works under all circumstances - or even works provably 100% reliably on one application - is extremely tricky.

Hell, writing locking code that does that is already tricky enough as soon as you move to fine grained locking. I wish there were tried and tested standalone lock free implementation of the most common structures that were actually lock free instead of the usual "let's fall back to locking because obviously lock free is always purely a throughput optimization" (spoiler: It is very much not).

-5

u/rzhxd Mar 24 '26

I don't know why are you trying to pick on someone so hard, but whatever. I'm not interested in justifying myself to you.

3

u/shadowndacorner Mar 24 '26

They're not picking on you. Everything they raised is valid, and I'd personally be interested in your answer.

-6

u/rzhxd Mar 24 '26

I'm not interested in answering.

3

u/shadowndacorner Mar 24 '26

Well alright, then lol

0

u/[deleted] Mar 24 '26

[deleted] — view deleted comment

1

u/rzhxd Mar 24 '26 edited Mar 24 '26

A person asked whether memory-mapping can be used to mirror a buffer. I provided an example, where it is used in such a case. What else do you want from me?