<div dir="auto">Wouldn't it make much more sense if we simply copied optimized copy routines from other libc implementations? They have specialised implementations for various architectures and microarchitectures (e.g. cache line size), not to mention the performance enhancements that have accumulated over time.<div dir="auto"><br></div><div dir="auto">Also worth noting is that Wine is licensed under LGPL, which makes it compatible with most open-source libcs out there. Basically what we would need is some ABI adaptations, such as calling convention adjustment and SEH.</div><div dir="auto"><br></div><div dir="auto">Another option is to just call system libc routines directly, although in this case it might interfere with stack unwinding, clear PE/unix separation, and msvcrt hotpatching.</div></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Sat, Apr 2, 2022, 1:45 PM Elaine Lefler <<a href="mailto:elaineclefler@gmail.com">elaineclefler@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">On Fri, Apr 1, 2022 at 7:13 AM Jan Sikorski <<a href="mailto:jsikorski@codeweavers.com" target="_blank" rel="noreferrer">jsikorski@codeweavers.com</a>> wrote:<br>
><br>
> Signed-off-by: Jan Sikorski <<a href="mailto:jsikorski@codeweavers.com" target="_blank" rel="noreferrer">jsikorski@codeweavers.com</a>><br>
> ---<br>
> It's about 13x faster on my machine than the byte version.<br>
> memcmp performance is important to wined3d, where it's used to find<br>
> pipelines in the cache, and the keys are pretty big.<br>
<br>
Should be noted that SSE2 also exists on 32-bit processors, and in<br>
this same file you can find usage of "sse2_supported", which would<br>
enable you to use this code path on i386. You can put<br>
__attribute__((target("sse2"))) on the declaration of sse2_memcmp to<br>
allow GCC to emit SSE2 instructions even when the file's architecture<br>
forbids it.<br>
<br>
I think this could be even faster if you forced ptr1 to be aligned by<br>
byte-comparing up to ((p1 + 15) & ~15) at the beginning. Can't<br>
reasonably force-align both pointers, but aligning at least one should<br>
give measurably better performance.<br>
<br>
I have a similar patch (labelled 230501 on<br>
<a href="https://source.winehq.org/patches/" rel="noreferrer noreferrer" target="_blank">https://source.winehq.org/patches/</a> - not sure how to link the whole<br>
discussion, sorry) which triggered a discussion about duplication<br>
between ntdll and msvcrt. memcmp is also a function that appears in<br>
both dlls. Do you have any input on that? (sorry if I'm out of line<br>
for butting in here. I just noticed we're working on the same basic<br>
thing)<br>
<br>
- Elaine<br>
<br>
</blockquote></div>