Closed ingmarkrause closed 5 years ago
~This is 32 bit, right?~ RSA in Windows 32 bit is very slow. Linux 32 and Windows 64 are both way better.
If at all possible use 2.8, as many optimizations have been made to RSA key generation since 2.4.0 (#1542 #1413 and several others). On my desktop (x86-64 Linux with GCC), 2.4 takes 6-10 seconds to generate a 4K bit RSA key, master is more like .3-1 second for same operation.
But @webmaster128 is correct MSVC 32-bit is the least well optimized of the options, we have very little inline asm for MSVC. That said you should still see a big improvement using latest release since most of the optimizations were algorithmic rather than additional inline asm. Compiling with GCC for 32-bit x86 with inline asm disabled, I see 4K keygen taking between ~ 2 and 5 seconds.
(RSA sign and verify are also 1.5-3x faster in 2.8 compared to 2.4, we have been doing a lot of optimization work in the last year, so that's another reason to upgrade.)
Thanks. 2.8 is indeed much faster (on my machine factor 20). In our case, it's currently not possible to switch to that new version, but probably in the near future. Here my results regarding the RSA 4096 key generation speed:
2.4.0: RSA-4096 0 keygen/sec; 54823.87 ms/op 150335295 cycles/op (1 op in 54824 ms)
2.8.0: RSA-4096 0 keygen/sec; 2817.95 ms/op 7727325 cycles/op (1 op in 2818 ms)
Wow, happy to hear that! That's a huge win given people install fresh 32 bit versions of Windows 10 in 2018 -.- Will check RSA keygen times again. Thanks and congratz to that achievement!
@randombit: Can you give me a hint, which commit(s) where responsible for the performance improvement between 2.4.0 and 2.8.0? Or is it too distributed over the commits? Thanks in advance!
Hello,
Switching from GnuTLS to Botan 2.4.0, we faced a big difference in the performance when creating a 4096 bit private key. While this operation takes 2-3 seconds with GnuTLS, it takes 40-180 seconds with Botan.
This is the used code:
where bitCount=4096. We are using VS2017 (VS toolset v141), and dynamically link to botan.dll.
When trying to create a key via the CLI tool, we achieved similar results (40-180 seconds):
.\botan-cli.exe keygen --params=4096
I did some profiling and found the following call tree:
Looks as if the
Montgomery_Exponentiator::execute
spends most of the time, especially inBigInt::const_time_lookup()
andbigint_monty_sqr()
Side information:
botan-cli.exe speed RSA
result in:When building botan,
configure.py
results in the following output:Example for the resulting compilation: