Follow @Openwall on Twitter for new release announcements and other news
[<prev] [next>] [day] [month] [year] [list]
Message-ID: <3016485f-0790-4634-ae6c-d9a05cdb79aa@gmail.com>
Date: Wed, 22 Jan 2020 18:12:28 +0100
From: Petr Skocik <pskocik@...il.com>
To: musl@...ts.openwall.com
Subject: faster memcmp

Hi,

I've noticed musl's implementation of memcmp was about way over times
slower than glibc's, which made memcpy-based comparisons of e.g.,
definitely contiguous structs actually quite a bit slower than applying
memcmp on them.

I've put together a memcmp that compares memory word by word if the
operands are aligned or identically misaligned (I figure the comparisons
of differently aligned objects is rare in real code).

It's still pretty compact, both in C (~40 LOC) and assembly (126 B @
x86_64 gcc -Os) and much closer to gcc's performance (less than twice
slower for comparison of 128B objects vs musl's 13 times).

If you like it, take it.

Regards,
Petr Skocik




View attachment "my_memcmp.c" of type "text/x-csrc" (1599 bytes)

Powered by blists - more mailing lists

Confused about mailing lists and their use? Read about mailing lists on Wikipedia and check out these guidelines on proper formatting of your messages.