mruby-bigint: raise Toom-3 threshold from 50 to 100 limbs

Benchmarks show the previous threshold of 50 was too low, causing
Toom-3's setup overhead to outweigh its asymptotic benefits for
medium-sized numbers. Raising to 100 limbs provides:

- 2x faster at 300 limbs (192 -> 96 us)
- 2.5x faster at 120 limbs (42 -> 17 us)
- 2.6x faster at 80 limbs (31 -> 12 us)

Co-authored-by: Claude <noreply@anthropic.com>
This commit is contained in:
Yukihiro "Matz" Matsumoto
2026-01-15 14:46:00 +09:00
parent 0220ec2b62
commit b0c1a31961
+1 -1
View File
@@ -972,7 +972,7 @@ mpz_sqr_basic_limbs(mp_limb *result, const mp_limb *x, size_t n)
* - Interpolate to recover result coefficients
*/
#define TOOM3_THRESHOLD 50
#define TOOM3_THRESHOLD 100
static inline mrb_bool
should_use_toom3(size_t n)