That looks pretty neat, but diff use case for sure. Mine is designed to be simple and fast, disruptor looks complex but faster. I'm happy with not being quite as fast for now, though I might add concurrent I/O later. It's already pretty fast through use of copy-by-long unsafe methods (>1GB/s).
Wouldn't you want to actually find out what the line size is (presumably of L1), and base it on that? Thanks for reminding me though, I'll add the power-of-two, it should help! Was distracted at the time.
What's the "copy-by-long" method? I know there are a number of fast copy by pointer techniques.... Most things that I've read lately indicate that Buffer.BlockCopy has comparable speeds to the unsafe methods. Have you benchmarked the differences? Cool project by the way.
Cast byte array pointer to long array pointer, then iterate over it, copying as you go. Means you copy 8 bytes per iteration, and not 1.
I've found the difference to be about 15% in favour of this approach (vs. Buffer.BlockCopy) for lengths between 64-1024 bytes, beyond that you get less difference.
Buffer.BlockCopy still needs to fix the array in memory (as the unsafe version does), but it also then needs to do a system call. So you see, it makes sense it would be this way.
So you know, I added concurrent I/O just now. Not full concurrency, with many reads and writes at once, but you can read and write (one operation of each) at once. I'll add full concurrency later. It's already a big speed boost.
Here is the RingBuffer from Disruptor, for the more Enterprisey folks.
It's the Disruptor-pattern ring buffer by LMAX, ported from Java to .NET.
Yes, I should have been more specific.
That looks pretty neat, but diff use case for sure. Mine is designed to be simple and fast, disruptor looks complex but faster. I'm happy with not being quite as fast for now, though I might add concurrent I/O later. It's already pretty fast through use of copy-by-long unsafe methods (>1GB/s).
Did you notice how their ring buffer size must be power of 2 for CPU cache coherence?
Wouldn't you want to actually find out what the line size is (presumably of L1), and base it on that? Thanks for reminding me though, I'll add the power-of-two, it should help! Was distracted at the time.
What's the "copy-by-long" method? I know there are a number of fast copy by pointer techniques.... Most things that I've read lately indicate that Buffer.BlockCopy has comparable speeds to the unsafe methods. Have you benchmarked the differences? Cool project by the way.
Cast byte array pointer to long array pointer, then iterate over it, copying as you go. Means you copy 8 bytes per iteration, and not 1. I've found the difference to be about 15% in favour of this approach (vs. Buffer.BlockCopy) for lengths between 64-1024 bytes, beyond that you get less difference. Buffer.BlockCopy still needs to fix the array in memory (as the unsafe version does), but it also then needs to do a system call. So you see, it makes sense it would be this way.
So you know, I added concurrent I/O just now. Not full concurrency, with many reads and writes at once, but you can read and write (one operation of each) at once. I'll add full concurrency later. It's already a big speed boost.