8 ms·
That was the same thought I had when I read through the ring buffer section. One glaring problem in the Golang space is the memory model doesn't offer Happens-
by jonathanoliver 11y ago
That was the same thought I had when I read through the ring buffer section.
One glaring problem in the Golang space is the memory model doesn't offer Happens-Before guarantees. I wrote a project called Go-Disruptor (github.com/smartystreets/go-disruptor) and found that I can't guarantee ordering of writes and reads between threads which is absolutely critical for a ring buffer implementation.
- jzelinskie 11y agoWould you mind expanding on this? I've never implemented a ring buffer and am genuinely curious.
- anon4 11y agoI haven't written Go, but from what I've heard it lets you mix in platform-specific assembly. Can't you use that to put in memory barriers and/or issue the specific load/store instructions you need?
- theparanoid 11y agoYou can, the Go runtime and standard library use assembly for a number of operations. A drawback is difficulty reading and reasoning about assembly. C style intrinsics are easier.
- deleted 11y ago[deleted]
- aleksi 11y ago> One glaring problem in the Golang space is the memory model doesn't offer Happens-Before guarantees. It does: https://golang.org/ref/mem#tmp_2 https://golang.org/ref/mem#tmp_2
- eternalban 11y ago> That was the same thought I had when I read through the ring buffer section. I am glad to see this being called out. I had the same precise 'wait a minute' response to that article.