mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tim Chen <tim.c.chen@linux.intel.com>
To: George Spelvin <linux@horizon.com>
Cc: david.m.cote@intel.com, herbert@gondor.apana.org.au,
	james.guilford@intel.com, JBeulich@suse.com,
	linux-kernel@vger.kernel.org, sandyw@twitter.com,
	wajdi.k.feghali@intel.com
Subject: Re: [PATCH v2] crypto: crc32c-pclmul - Shrink K_table to 32-bit words
Date: Thu, 29 May 2014 09:33:21 -0700	[thread overview]
Message-ID: <1401381201.2970.431.camel@schen9-DESK> (raw)
In-Reply-To: <20140529032655.27479.qmail@ns.horizon.com>

On Wed, 2014-05-28 at 23:26 -0400, George Spelvin wrote:
> > Can you do a tcrypt speed measurement with and without your changes?
> > Check to see if there's any slowdown.  Please make sure you pin
> > the frequency of your cpu when running the test.  
> > 
> > e.g.
> > echo performance > /sys/devices/system/cpu/cpu0/cpufreq/scaling_governor
> 
> I just now re-read your e-mail and noticed you suggested a specific tool.

Try to run the standard kernel crypto test with tcrypt.  For speed test
of crc32c, use test 319:

modprobe tcrypt mode=319

Then you will see the output in dmesg (or tail of /var/log/messages).
It will give you the cycles you spent for various block sizes.

For consistent test numbers, before test, 
disable turbo mode of cpu in BIOS and pin 
frequency of all your cpus to max with something like

i=0
num_cpus=`cat /proc/cpuinfo| grep "^processor"| wc -l `
while [ $i -lt $num_cpus ]
do
  echo performance > /sys/devices/system/cpu/cpu$i/cpufreq/scaling_governor
  i=`expr $i + 1`
done

> Oops, I haven't run that yet.  I just made up my own in user space.
> As I mentioned, since the changes are to the main loop that operates on
> aligned buffers in multiples of 24 bytes, I focused my benchmarking there:
> 
> #define BUFFER 6114
> static unsigned char buf[BUFFER] __attribute__ ((aligned(8)));
> #define ITER 24 /* Number of test iterations */
> 
> uint32_t
> do_test(uint32_t crc, uint32_t (*f)(void const *, unsigned, uint32_t))
> {
> 	int i, j;
> 	for (i = 0; i < BUFFER; i += 8)
> 		for (j = i+24; j <= BUFFER; j += 24)
> 			crc = f(buf+i, j-i, crc);
> 	return crc;
> }
> 
> uint32_t
> time_test(uint64_t *time, uint32_t crc, uint32_t (*f)(void const *, unsigned, ui
> nt32_t))
> {
> 	uint64_t start = rdtsc();
> 	crc = do_test(crc, f);
> 	*time = rdtsc() - start;
> 	return crc;
> }
> 
> The actual test goes in ABBA order to reduce bias:
> 
> 	for (i = 0; i < ITER; i += 2) {
> 		crc1 = time_test(times[i]+0, crc1, crc_pcl_1);
> 		crc2 = time_test(times[i]+1, crc2, crc_pcl_2);
> 		crc2 = time_test(times[i+1]+1, crc2, crc_pcl_2);
> 		crc1 = time_test(times[i+1]+0, crc1, crc_pcl_1);
> 	}
> 
> crc_pcl_1 is the old code, crc_pcl_2 is my revised version.
> 
> 
> The results are as follows (the last line is a total):
> 
>         Old code     New code
>  0:     85009953     71812457 (-13197496)
>  1:     57408829     63361572 (+5952743)

Maybe your cpu has not been pinned to constant frequency?
The cycles are much higher in the first few iterations.  
Likely cpu frequency is going up when governor detect 
the load on cpu. Please also check that turbo is 
turned off as this can introduce much variations
in your testing.

>  2:     52552399     49195266 (-3357133)
>  3:     43595130     45988364 (+2393234)
>  4:     41541760     39714198 (-1827562)
>  5:     36576082     38021344 (+1445262)
>  6:     35307854     34150656 (-1157198)
>  7:     32182230     33134236 (+952006)
>  8:     31341596     31307004 (-34592)
>  9:     31340900     31329408 (-11492)
> 10:     31344884     31329144 (-15740)
> 11:     31334144     31312492 (-21652)
> 12:     31338992     31330356 (-8636)
> 13:     31343744     31311344 (-32400)
> 14:     31339000     31340196 (+1196)
> 15:     31337492     31313988 (-23504)
> 16:     31341688     31334040 (-7648)
> 17:     31341804     31308936 (-32868)
> 18:     31339936     31332020 (-7916)
> 19:     31323228     31324240 (+1012)
> 20:     31339744     31331768 (-7976)
> 21:     31321536     31332688 (+11152)
> 22:     31340280     31335212 (-5068)
> 23:     31332056     31335768 (+3712)

Looks encouraging that the time difference is fairly
small between the two algorithms.

> 24:    885575261    876586697 (-8988564)

> 
> It doesn't look like a slowdown; more like a 1% speedup.

You will need to throw away the first few iterations of
the test to account for cache warming effects.

Thanks.

Tim


  reply	other threads:[~2014-05-29 16:33 UTC|newest]

Thread overview: 29+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-05-28 14:40 [RFC PATCH] crypto: crc32c-pclmul - Use pmovzxdq to shrink K_table George Spelvin
2014-05-28 15:32 ` George Spelvin
2014-05-28 22:15   ` [PATCH v2] crypto: crc32c-pclmul - Shrink K_table to 32-bit words George Spelvin
2014-05-28 23:02     ` Tim Chen
2014-05-28 23:55       ` George Spelvin
2014-05-29  3:26       ` George Spelvin
2014-05-29 16:33         ` Tim Chen [this message]
2014-05-28 20:47 ` [RFC PATCH] crypto: crc32c-pclmul - Use pmovzxdq to shrink K_table Jan Beulich
2014-05-28 21:47   ` George Spelvin
2014-05-29  6:44     ` Jan Beulich
2014-05-28 22:32 ` Tim Chen
2014-05-28 23:01   ` George Spelvin
2014-05-28 23:28     ` Tim Chen
2014-05-29 23:54       ` George Spelvin
2014-05-30  1:07         ` Tim Chen
2014-05-30  1:16           ` Dave Jones
2014-05-30 17:56             ` Tim Chen
2014-05-30 18:45               ` Dirk Brandewie
2014-05-30 19:32                 ` Tim Chen
2014-05-30 19:38                   ` Dirk Brandewie
2014-05-30 20:07                     ` Tim Chen
2014-05-30 20:15                       ` Dirk Brandewie
2014-05-30  1:37           ` George Spelvin
2014-05-30  5:25             ` George Spelvin
2014-05-30 16:10               ` Tim Chen
2014-05-30 16:52                 ` George Spelvin
2014-05-30 17:01                   ` Tim Chen
2014-06-07  3:08                     ` [PATCH v3] crypto: crc32c-pclmul - Shrink K_table to 32-bit words George Spelvin
2014-06-20 18:42                       ` Herbert Xu

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=1401381201.2970.431.camel@schen9-DESK \
    --to=tim.c.chen@linux.intel.com \
    --cc=JBeulich@suse.com \
    --cc=david.m.cote@intel.com \
    --cc=herbert@gondor.apana.org.au \
    --cc=james.guilford@intel.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@horizon.com \
    --cc=sandyw@twitter.com \
    --cc=wajdi.k.feghali@intel.com \
    /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

all inboxes | Powered by JetHome®