Open 1853582 opened 1 year ago
The previous one was the big database time of Go, while the latter one changed to GMP, which actually slowed down the time a lot.
The problem with gmp is that to call it requires switching to C calling conventions.
This article suggests that a normal function call in Go takes approx 1.8 nS whereas a call to a C function takes approx 170 nS.
The integers you are using are quite small so that overhead of 170 nS is much larger than the time the arithmetic operation takes.
This library really only comes into its own when using >100 digit or maybe 1,000 digit numbers.
What size are the integers you are using?
The number I use is an integer in the finite field Zp, p = 2 ^ 128-51
So a 128 bit number. I'd say that the CGO interface speed will negate any speed savings you might get from GMP here :-(
When I tested this GMP library, I found that its computational speed was much slower in my example than the built-in large data library of Go itself. Why is this? I am here to calculate the inner product composed of two arrays of large numbers, and then calculate many inner products.