linuxppc-dev.lists.ozlabs.org archive mirror
 help / color / mirror / Atom feed
From: Adhemerval Zanella <azanella@linux.vnet.ibm.com>
To: linuxppc-dev@lists.ozlabs.org
Subject: Re: [PATCH 1/2] powerpc: Add 64bit optimised memcmp
Date: Fri, 09 Jan 2015 09:01:29 -0200	[thread overview]
Message-ID: <54AFB509.8060808@linux.vnet.ibm.com> (raw)
In-Reply-To: <1420768591-6831-1-git-send-email-anton@samba.org>

On 08-01-2015 23:56, Anton Blanchard wrote:
> I noticed ksm spending quite a lot of time in memcmp on a large
> KVM box. The current memcmp loop is very unoptimised - byte at a
> time compares with no loop unrolling. We can do much much better.
>
> Optimise the loop in a few ways:
>
> - Unroll the byte at a time loop
>
> - For large (at least 32 byte) comparisons that are also 8 byte
>   aligned, use an unrolled modulo scheduled loop using 8 byte
>   loads. This is similar to our glibc memcmp.
>
> A simple microbenchmark testing 10000000 iterations of an 8192 byte
> memcmp was used to measure the performance:
>
> baseline:	29.93 s
>
> modified:	 1.70 s
>
> Just over 17x faster.
>
> Signed-off-by: Anton Blanchard <anton@samba.org>
>
Why not use glibc implementations instead? All of them (ppc64, power4, and
power7) avoids use byte at time compares for unaligned cases inputs; while
showing the same performance for aligned one than this new implementation.
To give you an example, a 8192 bytes compare with input alignment of 63/18
shows:

__memcmp_power7:  320 cycles
__memcmp_power4:  320 cycles
__memcmp_ppc64:   340 cycles
this memcmp:     3185 cycles

  parent reply	other threads:[~2015-01-09 11:01 UTC|newest]

Thread overview: 10+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-09  1:56 [PATCH 1/2] powerpc: Add 64bit optimised memcmp Anton Blanchard
2015-01-09  1:56 ` [PATCH 2/2] powerpc: Add memcmp testcase Anton Blanchard
2015-01-09 10:06 ` [PATCH 1/2] powerpc: Add 64bit optimised memcmp David Laight
2015-01-12  0:55   ` Anton Blanchard
2015-01-12  6:55     ` Joakim Tjernlund
2015-01-12  9:45       ` David Laight
2015-01-09 11:01 ` Adhemerval Zanella [this message]
  -- strict thread matches above, loose matches on Subject: below --
2015-01-21  1:27 Anton Blanchard
2015-01-21  9:26 ` Arnd Bergmann
2015-01-21 12:06   ` Anton Blanchard

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=54AFB509.8060808@linux.vnet.ibm.com \
    --to=azanella@linux.vnet.ibm.com \
    --cc=linuxppc-dev@lists.ozlabs.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).