News for hackers. Stuff that matters.
Re:A 100LOC C impl of memset, that is faster than glibc's by TonyTrapp on Friday November 12, 2021 @08:52AM (#29199233)
Assuming that vector instructions are available, shouldn't it be much faster to actually compare the buffer contents against a vector register initialized to all-zeros rather than comparing against some other memory? Or would memcmp automatically optimize that away because of the precondition that the first 16 bytes are already known to be 0?
Re:A 100LOC C impl of memset, that is faster than glibc's by BeeOnRope on Friday November 12, 2021 @09:22AM (#29199495)
It is probably faster, yes (half the number of reads) – but the point of this truck is that you can re-use the (hopefully) vectorized memcmp on every platform with portable code rather than getting on the SIMD ISA treadmill yourself.
Re:A 100LOC C impl of memset, that is faster than glibc's by rwmj on Friday November 12, 2021 @10:20AM (#29200074)
The qemu implementation does indeed do it the hard way. It's a lot of code: https://gitlab.com/qemu-project/qemu/-/blob/master/util/buff...
Re:A 100LOC C impl of memset, that is faster than glibc's by pm215 on Friday November 12, 2021 @03:39PM (#29204261)
Interestingly, we used to have a special-case aarch64 version, but we dropped it because the C version was faster: https://gitlab.com/qemu-project/qemu/-/commit/2250d3a293d36e...

(Might or might not still be true on more modern aarch64 hardware...)

Re:A 100LOC C impl of memset, that is faster than glibc's by pm215 on Friday November 12, 2021 @04:25PM (#29204711)
Does your memset version beat QEMU's plain-old-C fallback version ?