You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
AMD Phenom II X4 945: aes-128-ctr no-asm faster than default? #9640
I think your performance numbers are influenced by building openssl twice,
that will heat up the core and the frequncey will probably be throttled.
That might make the second performance measurement look worse.
I saw a similar effect when I used you work-flow.
Instead try building the asm and no-asm in different build directories,
and allow some time to cool down between the tests.
Ok... wrote some perl script which checks (parallel, fork()) cpu MHz from /proc/cpuinfo (the lines with the 4 numbers, expressed as GHz) every 0.2s and sensors cpu temperature every 1s...
here the output of openssl speed -evp aes-128-ctr compiled with ./config without options:
Ah, well, so it is not a thermal problem.
But I still don't know what is wrong.
I assume you don't have a environment variable OPENSSL_ia32cap,
if you do please remove that since it can cause sub-optimal performance.
I own a similar CPU: according to /proc/cpuinfo
it's a AMD A10-5750M APU with Radeon(tm) HD Graphics
So when I build current 1.1.1-stable with no-asm I get:
$ apps/openssl speed -evp aes-128-ctr
Doing aes-128-ctr for 3s on 16 size blocks: 24445846 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 64 size blocks: 7361130 aes-128-ctr's in 2.99s
Doing aes-128-ctr for 3s on 256 size blocks: 1936758 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 1024 size blocks: 491232 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 8192 size blocks: 61622 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 16384 size blocks: 30889 aes-128-ctr's in 3.00s
OpenSSL 1.1.1d-dev xx XXX xxxx
built on: Wed Aug 21 21:49:38 2019 UTC
options:bn(64,64) rc4(int) des(int) aes(partial) idea(int) blowfish(ptr)
compiler: gcc -pthread -m64 -Wall -O3 -DOPENSSL_USE_NODELETE -DL_ENDIAN -DNDEBUG
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
aes-128-ctr 130377.85k 157562.65k 165270.02k 167673.86k 168269.14k 168695.13k
and with asm:
$ apps/openssl speed -evp aes-128-ctr
Doing aes-128-ctr for 3s on 16 size blocks: 55324223 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 64 size blocks: 39059428 aes-128-ctr's in 2.99s
Doing aes-128-ctr for 3s on 256 size blocks: 16328388 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 1024 size blocks: 5108670 aes-128-ctr's in 3.00s
Doing aes-128-ctr for 3s on 8192 size blocks: 707156 aes-128-ctr's in 2.99s
Doing aes-128-ctr for 3s on 16384 size blocks: 355776 aes-128-ctr's in 2.99s
OpenSSL 1.1.1d-dev xx XXX xxxx
built on: Thu Aug 22 08:59:21 2019 UTC
options:bn(64,64) rc4(8x,int) des(int) aes(partial) idea(int) blowfish(ptr)
compiler: gcc -pthread -m64 -Wa,--noexecstack -Wall -O3 -g -DOPENSSL_USE_NODELETE -DL_ENDIAN -DOPENSSL_CPUID_OBJ -DOPENSSL_IA32_SSE2 -DOPENSSL_BN_ASM_MONT -DOPENSSL_BN_ASM_MONT5 -DOPENSSL_BN_ASM_GF2m -DSHA1_ASM -DSHA256_ASM -DSHA512_ASM -DKECCAK1600_ASM -DRC4_ASM -DMD5_ASM -DAES_ASM -DVPAES_ASM -DBSAES_ASM -DGHASH_ASM -DECP_NISTZ256_ASM -DX25519_ASM -DPOLY1305_ASM -DNDEBUG
The 'numbers' are in 1000s of bytes per second processed.
type 16 bytes 64 bytes 256 bytes 1024 bytes 8192 bytes 16384 bytes
aes-128-ctr 295062.52k 836054.65k 1393355.78k 1743759.36k 1937465.54k 1949509.69k
no, there is no openssl-like environment variable (ubuntu 18.04 amd64, nothing special)
ok, tried to patch
patch < patch.txt
can't find file to patch at input line 5
Perhaps you should have used the -p or --strip option?
The text leading up to this was:
--------------------------
|diff --git a/apps/speed.c b/apps/speed.c
|index 2014950..6ee35d8 100644
|--- a/apps/speed.c
|+++ b/apps/speed.c
--------------------------
File to patch: apps/speed.c
patching file apps/speed.c
then
./config -no-pic
make -j4
...
${LDCMD:-gcc} -pthread -m64 -Wa,--noexecstack -Wall -O3 -L. \
-o test/cipherlist_test test/cipherlist_test.o \
-lssl test/libtestutil.a -lcrypto -ldl -pthread
test/cipher_overhead_test.o: In function `cipher_overhead':
cipher_overhead_test.c:(.text+0x1f): undefined reference to `ssl3_num_ciphers'
cipher_overhead_test.c:(.text+0x81): undefined reference to `ssl3_get_cipher'
cipher_overhead_test.c:(.text+0xa2): undefined reference to `ssl_cipher_get_overhead'
collect2: error: ld returned 1 exit status
Makefile:8168: recipe for target 'test/cipher_overhead_test' failed
make[1]: *** [test/cipher_overhead_test] Error 1
make[1]: *** Waiting for unfinished jobs....
make[1]: Leaving directory '/home/jb/workspace/cipher/openssl-1.1.1c'
Makefile:172: recipe for target 'all' failed
make: *** [all] Error 2
Your CPU does not support AESNI instructions, bit 0x200000000000000 in the OPENSSL_ia32cap.
Actually not any hardware acceleration for AES seems to be available, therefore the performance
is not very good. Apparently the default implementation is using key bits as indexes in the tables
and is therefore not executing in constant time but neither is the software implementation.
Yes, it's a Phenom II X4... no AESNI. Is "constant time" preferred because side channel attacks? Then my speed comparison with Crypto++ is perhaps unfair... Thanks!
Yes there is a small side channel due to the non-constant time AESNI is both faster and more secure.
alternative approaches are possible using bit-slicing, especially for ctr mode, but unfortunately
the assember module is slower but still not constant time.
Activity
bernd-edlinger commentedon Aug 20, 2019
I think your performance numbers are influenced by building openssl twice,
that will heat up the core and the frequncey will probably be throttled.
That might make the second performance measurement look worse.
I saw a similar effect when I used you work-flow.
Instead try building the asm and no-asm in different build directories,
and allow some time to cool down between the tests.
msalat commentedon Aug 21, 2019
Ok... wrote some perl script which checks (parallel, fork()) cpu MHz from /proc/cpuinfo (the lines with the 4 numbers, expressed as GHz) every 0.2s and sensors cpu temperature every 1s...
here the output of
openssl speed -evp aes-128-ctrcompiled with./configwithout options:and now with
./config no-asm:bernd-edlinger commentedon Aug 22, 2019
Ah, well, so it is not a thermal problem.
But I still don't know what is wrong.
I assume you don't have a environment variable
OPENSSL_ia32cap,if you do please remove that since it can cause sub-optimal performance.
I own a similar CPU: according to /proc/cpuinfo
it's a
AMD A10-5750M APU with Radeon(tm) HD GraphicsSo when I build current 1.1.1-stable with no-asm I get:
and with asm:
Could you please try this patch
It need to be built with no-pic because the symbol is in crypto and usually not exported.
So this prints on my system the following
OPENSSL_ia32cap=0x3e983a0b078bffff:0x8
What do you get on your system?
msalat commentedon Aug 22, 2019
no, there is no openssl-like environment variable (ubuntu 18.04 amd64, nothing special)
ok, tried to patch
then
what I'm doing wrong?
bernd-edlinger commentedon Aug 22, 2019
I guess you need to make distclean first.
bernd-edlinger commentedon Aug 22, 2019
and no "-" in no-pic
msalat commentedon Aug 22, 2019
ok, did make distclean; there is no ./config nopic, just ./config no-pic
Output:
bernd-edlinger commentedon Aug 22, 2019
Your CPU does not support AESNI instructions, bit 0x200000000000000 in the OPENSSL_ia32cap.
Actually not any hardware acceleration for AES seems to be available, therefore the performance
is not very good. Apparently the default implementation is using key bits as indexes in the tables
and is therefore not executing in constant time but neither is the software implementation.
msalat commentedon Aug 22, 2019
Yes, it's a Phenom II X4... no AESNI. Is "constant time" preferred because side channel attacks? Then my speed comparison with Crypto++ is perhaps unfair... Thanks!
bernd-edlinger commentedon Aug 22, 2019
Yes there is a small side channel due to the non-constant time AESNI is both faster and more secure.
alternative approaches are possible using bit-slicing, especially for ctr mode, but unfortunately
the assember module is slower but still not constant time.
bernd-edlinger commentedon Aug 23, 2019
And by the way, thanks for reporting this.
So this means probably we can drop this specific assembler module.
bernd-edlinger commentedon Aug 23, 2019
Fix in #9675 you can try it, if you want, it should even improve
on 32bit ./Configure linux-x86
msalat commentedon Aug 23, 2019
much better:
Remove x86/x86_64 BSAES and AES_ASM support
Remove x86/x86_64 BSAES and AES_ASM support
Remove x86/x86_64 BSAES and AES_ASM support