FiloSottile / FiloSottile/edwards25519

perf: Consider something like `pow2k`

Open
#23 4 comments 1 reaction 0 assignees View on GitHub
Dominant language
Go
Stars
188
Forks
39
PR merge metrics
No merged PRs in 30d

Description

Both `Invert` and `Pow22523` repeatedly square in a loop. The overhead of repeatedly calling Square (and having to shuffling data in/out of registers) adds up to a decent chunk of execution time.

Doing something like `func (v *Element) pow2k(x *Element, k uint)` with the precondition that `k >= 1`, dramatically improves performance of the two operations like thus:

```
Invert-4 11.3µs ± 0% 7.1µs ± 0% -37.33%
Pow22523-4 11.1µs ± 0% 7.0µs ± 0% -37.32%
```

Numbers taken with `purego`, but the amd64 assembly implementation will also benefit (and can be written without having to spill to the stack at all).

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.