On Thu, Sep 12, 2013 at 04:51:48PM +0100, Brad Fitzpatrick wrote:
> On Thu, Sep 12, 2013 at 4:44 PM, Ian Lance Taylor <
ia...@golang.org> wrote:
>
> > On Thu, Sep 12, 2013 at 6:01 AM, Piotr Narewski <
piot...@gmail.com>
> > wrote:
> > > Are there any plans on the road map to do something about the
> > performance of
> > > the big number package?
> > >
> > > Since a public key cryptography is very important these days, I would
> > like
> > > to appeal to the devs to address this problem as soon as possible.
> > > I understand that it might require bringing it down to the assembly
> > level,
> > > but well... it wouldn't be the only package.
> >
> > To be clear, math/big already uses assembly code.
> >
> > I would encourage you to open an issue with some benchmarks (see the
> > existing BenchmarkXXX in math/big/*_test.go), and if possible point to
> > what specific code in math/big needs to speed up.
> >
>
> I don't see much CPU time being spent in math/big.
>
[..]
> + c := elliptic.P224()
elliptic.P224 has a separate (constant-time) implementation that doesn't really
use math/big (elliptic.p224Curve).
The profile looks different for curves using the generic implementation
(elliptic.CurveParams).
For elliptic.P256():
128 13.4% 13.4% 452 47.2% math/big.nat.divLarge
76 7.9% 21.3% 76 7.9% math/big.divWW
54 5.6% 26.9% 262 27.3% runtime.makeslice
53 5.5% 32.5% 53 5.5% math/big.addMulVVW
53 5.5% 38.0% 260 27.1% runtime.mallocgc
40 4.2% 42.2% 40 4.2% math/big.mulAddVWW
37 3.9% 46.0% 37 3.9% runtime.markallocated
33 3.4% 49.5% 33 3.4% runtime.memclr
28 2.9% 52.4% 34 3.5% sweepspan
27 2.8% 55.2% 197 20.6% cnew
27 2.8% 58.0% 27 2.8% math/big.subVV
25 2.6% 60.6% 85 8.9% math/big.basicMul
24 2.5% 63.2% 33 3.4% scanblock
21 2.2% 65.3% 21 2.2% math/big.nat.norm
20 2.1% 67.4% 98 10.2% runtime.MCache_Alloc
18 1.9% 69.3% 482 50.3% math/big.(*Int).QuoRem
17 1.8% 71.1% 191 19.9% math/big.nat.mul
17 1.8% 72.9% 19 2.0% runtime.settype_flush
14 1.5% 74.3% 57 5.9% math/big.(*Int).Sub
14 1.5% 75.8% 14 1.5% math/big.nat.clear