Issue 1618455: HMAC can get a 6x performance increase easily (original) (raw)

Issue1618455

Created on 2006-12-18 23:12 by bmaurer, last changed 2022-04-11 14:56 by admin. This issue is now closed.

Files
File name Uploaded Description Edit
py.patch bmaurer,2006-12-18 23:12 patch
Messages (3)
msg30827 - (view) Author: Ben Maurer (bmaurer) Date: 2006-12-18 23:12
The attached patch increases the performance of HMAC by a factor of 6. It does so by avoiding useing join/map in the strxor and using a lookup table. It would be faster just to do xor at the string level, but it's not clear that can be done without help from C.
msg30828 - (view) Author: A.M. Kuchling (akuchling) * (Python committer) Date: 2006-12-19 14:16
Thanks for your patch; I've modified it to remove _strxor() completely and applied the change as rev. 53065. When I tried a trivial benchmark, the speed improvement wasn't anywhere near 6X, and was more like 7%. The patch is still worth applying because it also simplifies the code.
msg30829 - (view) Author: Ben Maurer (bmaurer) Date: 2006-12-19 14:58
The performance increase is if you call hmac.new a lot. I did a benchmark on a relatively small amount of cleartext (50 bytes). This was actually something I needed to use. One thing I found -- reusing teh same hmac option helps *ALOT* the hmac docs don't make it clear how much this will help.
History
Date User Action Args
2022-04-11 14:56:21 admin set github: 44359
2006-12-18 23:12:40 bmaurer create