math/big: Implement fft algorithm #42267
Labels
NeedsDecision
Feedback is required from experts, contributors, and/or the community before a change can be made.
Performance
Milestone
From #30943. I think it's time for us to add fft to the big package. This implements Schönhage–Strassen algorithm in math/big and increased the multiplication speed several times to tens of times (depending on the length of the input). Although it is still not as fast as in GMP( which uses an advanced and more complex algorithm), it should solve the bottleneck of Go in multiplication of very large numbers(#30943, for example).
The benchmark test data is as follows:
Mul-4 12.5ms ± 1% 6.9ms ± 3% -45.08% (p=0.016 n=4+5)
NatMul/10-4 251ns ± 3% 267ns ± 6% +6.28% (p=0.008 n=5+5)
NatMul/100-4 8.64µs ± 3% 8.80µs ± 1% ~ (p=0.310 n=5+5)
NatMul/1000-4 358µs ± 5% 355µs ± 3% ~ (p=0.841 n=5+5)
NatMul/10000-4 12.6ms ± 2% 7.0ms ± 5% -44.11% (p=0.008 n=5+5)
NatMul/100000-4 545ms ± 4% 90ms ± 3% -83.43% (p=0.008 n=5+5)
NatMul/1000000-4 21.2s ± 2% 1.2s ± 4% -94.33% (p=0.008 n=5+5)
The text was updated successfully, but these errors were encountered: