[Botan-devel] Botan performance issues
Jack Lloyd
lloyd at randombit.net
Fri Dec 30 12:57:09 EST 2005
[CC'ing monotone-devel as this may be of some interest to people on that list]
I've been doing some analysis to try to get a feel for how much performance can
be improved in Botan, particularly in the area public key algorithms. This
summer (largely due to assistance and feedback from a couple of people working
on Monotone) many of the hash functions and symmetric ciphers ended up getting
significantly faster, and I'd like to do the same for the public key algorithms.
I've been running some benchmarks and comparing Botan's RSA/DSA performance
against some other implementations. Specifically, I ran the Botan benchmarks
using the OpenSSL and GNU MP backends; in this way, the only difference is the
very low-level code (the results of which show that there can be major
performance gains without having to modify any but the lowest-level PK
implementation code). I ran the tests using OpenSSL 0.9.8a configured with
no-asm (which I'm taking as "the best you can do in semi-reasonable C"),
OpenSSL 0.9.8a with assembly (the default performance comparison), and GNU MP
4.1.4 (which probably shows something fairly close to the hardware limit). All
three were built as static libraries to free up the PIC register (I ran these
tests using both shared and and static libraries, and using static libs had a
substantial positive impact). The full results are attached.
My performance goal right now is for RSA/DSA/DH using plain out of the box
Botan to be as fast as using Botan with the OpenSSL engine, backing to latest
OpenSSL version configured with no-asm. Right now, we are off that by 15% and
200% typically, and 800+% in some extreme cases.
Here is my initial things-to-do on this project:
- Check performance of bigint_mul3 (and possibly of bigint_smul,
bigint_comba[468], and bigint_karat* individually) against OpenSSL's
BN - if there is a major difference, figure out why
- Do the same for raw power_mod calls
- Profile PK operations using both Botan's default engine and the OpenSSL
engine, and see where we are losing time (using oprofile, cachegrind, or
some other finely-tuned profiler - I've never gotten particularly useful
results out of gprof for this).
- Identify algorithms which may be superior to the ones currently in use
(Chapter 14 of the Handbook of Applied Cryptography will be a reasonable
start); implement, test, profile, and benchmark them. Obvious starting
points are Montgomery multiplication/reduction, floating window
exponentiation, and optimizations and precomputations for fixed exponents,
such as addition chains.
- Try to get the low-level C/C++ to compile to more efficient code (reducing
temporaries, better use of software pipelining, inlining, etc) on typical
compilers.
- Potentially write assembler implementations for common platforms (I'm
considering this a last resort)
The major reason for this email is that, basically, I could use some help. I've
got a lot of things going on and don't really have time to spend too many hours
each week on Botan. So, if you wish Botan was faster, and a) can help out with
anything above, or have any suggestions/hints/ideas, or b) know of a person or
company who would like to sponsor this work, please drop me an email.
Jack
-------------- next part --------------
Compiler: GCC 4.0.2 20051125 (Red Hat 4.0.2-8)
Hardware: 800 MHz Athlon, 512 Mb RAM, KX133 chipset
OS: Fedora Core 4
All results are in operations / second
Botan 1.4.10
RSA-512: 1016.60 (encrypt/verify)
RSA-512: 39.90 (decrypt/sign)
RSA-1024: 561.40 (encrypt/verify)
RSA-1024: 14.87 (decrypt/sign)
RSA-1536: 389.80 (encrypt/verify)
RSA-1536: 6.71 (decrypt/sign)
RSA-2048: 264.60 (encrypt/verify)
RSA-2048: 3.49 (decrypt/sign)
RSA-3072: 166.80 (encrypt/verify)
RSA-3072: 1.51 (decrypt/sign)
RSA-4096: 116.70 (encrypt/verify)
RSA-4096: 0.72 (decrypt/sign)
DSA-512: 44.36 (verify)
DSA-512: 73.63 (sign)
DSA-768: 30.70 (verify)
DSA-768: 53.90 (sign)
DSA-1024: 22.20 (verify)
DSA-1024: 40.32 (sign)
OpenSSL O.9.8a (no-asm)
RSA-512: 1924.30 (encrypt/verify)
RSA-512: 322.90 (decrypt/sign)
RSA-1024: 893.40 (encrypt/verify)
RSA-1024: 63.04 (decrypt/sign)
RSA-1536: 489.30 (encrypt/verify)
RSA-1536: 21.96 (decrypt/sign)
RSA-2048: 304.40 (encrypt/verify)
RSA-2048: 10.06 (decrypt/sign)
RSA-3072: 145.50 (encrypt/verify)
RSA-3072: 3.22 (decrypt/sign)
RSA-4096: 89.30 (encrypt/verify)
RSA-4096: 1.46 (decrypt/sign)
DSA-512: 202.30 (verify)
DSA-512: 257.30 (sign)
DSA-768: 102.30 (verify)
DSA-768: 164.90 (sign)
DSA-1024: 61.44 (verify)
DSA-1024: 104.80 (sign)
OpenSSL 0.9.8a
RSA-512: 2581.50 (encrypt/verify)
RSA-512: 531.80 (decrypt/sign)
RSA-1024: 1591.40 (encrypt/verify)
RSA-1024: 132.20 (decrypt/sign)
RSA-1536: 953.60 (encrypt/verify)
RSA-1536: 45.60 (decrypt/sign)
RSA-2048: 681.80 (encrypt/verify)
RSA-2048: 24.03 (decrypt/sign)
RSA-3072: 325.50 (encrypt/verify)
RSA-3072: 7.40 (decrypt/sign)
RSA-4096: 219.70 (encrypt/verify)
RSA-4096: 3.72 (decrypt/sign)
DSA-512: 410.00 (verify)
DSA-512: 400.20 (sign)
DSA-768: 207.00 (verify)
DSA-768: 289.70 (sign)
DSA-1024: 144.10 (verify)
DSA-1024: 212.70 (sign)
GNU MP 4.1.4
RSA-512: 3968.80 (encrypt/verify)
RSA-512: 773.40 (decrypt/sign)
RSA-1024: 2212.90 (encrypt/verify)
RSA-1024: 169.90 (decrypt/sign)
RSA-1536: 1309.80 (encrypt/verify)
RSA-1536: 60.50 (decrypt/sign)
RSA-2048: 863.60 (encrypt/verify)
RSA-2048: 28.64 (decrypt/sign)
RSA-3072: 450.50 (encrypt/verify)
RSA-3072: 9.34 (decrypt/sign)
RSA-4096: 276.60 (encrypt/verify)
RSA-4096: 4.30 (decrypt/sign)
DSA-512: 539.20 (verify)
DSA-512: 517.00 (sign)
DSA-768: 283.80 (verify)
DSA-768: 389.40 (sign)
DSA-1024: 175.70 (verify)
DSA-1024: 261.30 (sign)
More information about the botan-devel
mailing list