mmcloughlin / ec3

Elliptic Curve Cryptography Compiler: an incomplete experiment in code-generation for elliptic curves in Go
BSD 3-Clause "New" or "Revised" License
56 stars 6 forks source link

gen/fp: mark assembly functions go:noescape #91

Closed mmcloughlin closed 5 years ago

mmcloughlin commented 5 years ago

Early results on curve benchmarks #90 show an insane amount of time in runtime.newobject and consequently also in GC.

ScalarMult Flamegraph

After some experimentation it became clear that escape analysis was choosing to allocate Add/Double temporaries on the heap because they are passed to the field functions in assembly, which it knows nothing about. Adding //go:noescape manually to the functions below solves the problem and massively improves performance.

https://github.com/mmcloughlin/ec3/blob/e47ab401d787aceb24bbba12a923c67225f063df/examples/p256/fp_amd64.go#L3-L11

Need to ensure the noescape directive is added to all these function stubs. Depends on mmcloughlin/avo#15.