From 22a79fe7336012dc1ad9aa218daf6bd3d8b4419c Mon Sep 17 00:00:00 2001 From: Simon Tatham Date: Thu, 3 Jan 2019 11:39:14 +0000 Subject: [PATCH] mpint tuning: lower KARATSUBA_THRESHOLD to 24. The new testcrypt system made it easy to write a tiny Python program that does a lot of multiplications of various large sizes, run it against versions of the testcrypt binary built with lots of different threshold settings, and time the output by running the Python program with PUTTY_TESTCRYPT="command time -f %U ./testcrypt". When I tried that I found that lots of values in the 20-30 range looked about as good as each other. 24 was an unusually low dip which could well have just been a random outlier, but it's a nice round number so I picked it anyway. --- mpint.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mpint.c b/mpint.c index 28b91d81..577cc026 100644 --- a/mpint.c +++ b/mpint.c @@ -871,7 +871,7 @@ static void mp_mul_add_simple(mp_int *r, mp_int *a, mp_int *b) } #ifndef KARATSUBA_THRESHOLD /* allow redefinition via -D for testing */ -#define KARATSUBA_THRESHOLD 50 +#define KARATSUBA_THRESHOLD 24 #endif static inline size_t mp_mul_scratchspace_unary(size_t n)