Project

General

Profile

Actions

Bug #1542

closed

bad crypto performance (using openssl)

Added by alexh over 14 years ago. Updated over 13 years ago.

Status:
Closed
Priority:
Normal
Assignee:
Category:
-
Target version:
-
Start date:
Due date:
% Done:

0%

Estimated time:

Description

Results of a few tests on my soekris net5501 box (no, I'm not using the crypto
hardware; yes I am sure about that):

-------------------------------------------------------------------------
dragonfly# openssl speed aes-128-cbc
...
OpenSSL 0.9.8k 25 Mar 2009
built on: Sat Sep 26 09:03:11 BST 2009
options:bn(64,32) md2(int) rc4(idx,int) des(ptr,risc1,16,long) aes(partial)
blowfish(idx)
...
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 4072.40k 4231.00k 4268.95k 4291.97k 4283.60k

pfSense:~# openssl speed aes-128-cbc
...
OpenSSL 0.9.8e 23 Feb 2007
built on: Sun Feb 24 16:11:39 UTC 2008
options:bn(64,32) md2(int) rc4(idx,int) des(ptr,risc1,16,long) aes(partial)
blowfish(idx)
...
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 5436.43k 5587.18k 5658.61k 5670.01k 5681.02k

dragonfly# dd if=/dev/zero bs=4k count=100000 | openssl enc -aes-128-cbc -e -
out /dev/null -nosalt -k abcdefhij
100000+0 records in
100000+0 records out
409600000 bytes transferred in 103.347777 secs (3963317 bytes/sec)

pfSense:~# dd if=/dev/zero bs=4k count=100000 | openssl enc -aes-128-cbc -e -
out /dev/null -nosalt -k abcdefhij
100000+0 records in
100000+0 records out
409600000 bytes transferred in 89.482008 secs (4577457 bytes/sec)

-------------------------------------------------------------------------
Results of the same tests on the same VMWare virtual machine:

dragonfly (openssl compiled with -O2):
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 62175.25k 62713.00k 64060.00k 64069.51k 64250.39k

freebsd (seems to be compiled with -O2 -DOPENSSL_THREADS:
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 81097.86k 84583.24k 86055.15k 86210.96k 86484.81k

dd:
dragonfly:
409600000 bytes transferred in 7.676454 secs (53357969 bytes/sec)

freebsd:
409600000 bytes transferred in 5.239756 secs (78171577 bytes/sec)


And even more, running time -l openssl speed aes-128-cbc:

dragonfly:
aes-128 cbc 62038.39k 62486.35k 64122.89k 64131.56k 64477.89k
15.11 real 15.06 user 0.01 sys
2144 maximum resident set size
132 average shared memory size
7 average unshared data size
49 average unshared stack size
448 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
10 signals received
0 voluntary context switches
0 involuntary context switches

freebsd:
aes-128 cbc 81091.22k 84641.53k 85396.39k 86787.24k 85657.43k
15.26 real 15.08 user 0.01 sys
2816 maximum resident set size
368 average shared memory size
367 average unshared data size
128 average unshared stack size
209 page reclaims
0 page faults
0 swaps
0 block input operations
0 block output operations
0 messages sent
0 messages received
5 signals received
1 voluntary context switches
1463 involuntary context switches

----------------------
on a different issue, 0 involuntary context switches? doesn't sound right.


Files

i386 (17.6 KB) i386 peter, 11/22/2010 11:29 AM
i386-asm (17.6 KB) i386-asm peter, 11/22/2010 11:29 AM
x86_64 (17.7 KB) x86_64 peter, 11/22/2010 11:29 AM
x86_64-asm (17.7 KB) x86_64-asm peter, 11/22/2010 11:29 AM
Actions #1

Updated by alexh over 14 years ago

ok, I've tried with a pkgsrc compiled one on a different machine, and also with
our base openssl, results:
pkgsrc:
% LD_LIBRARY_PATH=. apps/openssl speed aes-128-cbc
...
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 32231.84k 50363.14k 58405.02k 56728.83k 63585.82k

native:
...
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes
aes-128 cbc 24142.68k 24968.12k 25585.41k 25565.77k 24387.99k

Something is seriously wrong with our configuration, and I assume it to be the
missing -DOPENSSL_THREADS.

Actions #2

Updated by corecode over 14 years ago

Alex Hornung (via DragonFly issue tracker) wrote:

Something is seriously wrong with our configuration, and I assume it to be the
missing -DOPENSSL_THREADS.

Maybe also missing assembler code.

cheers
simon

Actions #3

Updated by pavalos over 13 years ago

I'm working on bringing in asm code and threading for openssl.

Actions #4

Updated by pavalos over 13 years ago

Well I have i386 working, but I'm getting the following error with x86_64:

/home/pavalos/root/usr/obj/home/pavalos/pavalos/ctools_x86_64_x86_64/usr/libexe
c/binutils217/elf/ld: x86_64cpuid.So: relocation R_X86_64_PC32 against
`OPENSSL_cpuid_setup' can not be used when making a shared object; recompile
with -fPIC
/home/pavalos/root/usr/obj/home/pavalos/pavalos/ctools_x86_64_x86_64/usr/libexe
c/binutils217/elf/ld: final link failed: Bad value
  • Error code 1

Stop in /home/pavalos/pavalos/secure/lib/libcrypto.

Anyone have any ideas on that?

You can see the work at git://git.theshell.com/pavalos.git

Actions #5

Updated by pavalos over 13 years ago

Ok, looks like I have x86_64 working now. I need to pass -Bsymbolic to the
linker. I'm running through a few more tests, and I'll commit later on.
Expect an email comparing speeds next...

Actions #6

Updated by peter over 13 years ago

Ok, OpenSSL now uses vendor-provided assembly in libcrypto as of
aa1f363092970a87daaa258f83ca0fd6be992888. Attached are some files
recording the output of openssl speed:

i386 - no assembly on the i386 arch
i386-asm - assembly on the i386 arch
x86_64 - no assembly on the x86_64 arch
x86_64-asm - assembly on the x86_64 arch

--Peter

Actions #7

Updated by mneumann over 13 years ago

Strange, for x86_64 aes-128 (and others) are much slower for small sizes
with asm than without.

with asm:

aes-128 cbc 99800.49k 106699.15k 108852.40k 277620.74k
281411.58k

w/o asm:

aes-128 cbc 146135.83k 155790.60k 158851.09k 159470.71k
159413.51k

Regards,

Michael
Actions

Also available in: Atom PDF