iopipe v0.0.4 - RingBuffers!
Steven Schveighoffer
schveiguy at yahoo.com
Fri May 11 13:32:20 UTC 2018
On 5/11/18 5:55 AM, Kagamin wrote:
> On Thursday, 10 May 2018 at 23:22:02 UTC, Steven Schveighoffer wrote:
>> However, I am struggling to find a use case for this that showcases
>> why you would want to use it. While it does work, and works
>> beautifully, it doesn't show any measurable difference vs. the array
>> allocated buffer that copies data when it needs to extend.
>
> Depends on OS and hardware. I would expect mmap implementation to be
> slower as it reads file in chunks of 4kb and relies on page faults.
As Dmitry hinted at, there actually is no file involved. I'm mapping
just straight memory to 2 segments. In fact, in my test application, I'm
using stdin as the input, which may not even involve a file.
It's just as fast as using memory, the only cool part is that you can
write a buffer that wraps to the beginning as if it were a normal array.
What surprises me is that the copying for the normal buffer doesn't hurt
performance that much. I suppose this should probably have been
expected, as CPUs are really really good at processing consecutive
memory, and the copying you end up having to do is generally small
compared to the rest of your app.
-Steve
More information about the Digitalmars-d-announce
mailing list