Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pippenger for G1 scalar_mul (single-threaded), add_mixed optimisation #81

Closed
jon-chuang opened this issue Apr 3, 2020 · 6 comments
Closed
Labels
T-performance Type: performance improvements

Comments

@jon-chuang
Copy link
Contributor

In order to match gnark timings for G1, we should bring mul_assign timings down to 220us from 270us. add_mixed should be brought down from 750us to 705us.

gnark uses the following algorithm credited to Jonathan Bootle: https://jbootle.github.io/Misc/pippenger.pdf.

@jon-chuang jon-chuang changed the title Pippenger for scalar mul (single-threaded), add_mixed optimisation Pippenger for G1 scalar_mul (single-threaded), add_mixed optimisation Apr 3, 2020
@burdges
Copy link
Contributor

burdges commented Apr 5, 2020

At some point the Edwards "Jubjub" curves could benefit form Pippenger too, although maybe that code should be modeled on dalek or something, not sure.

@Pratyush
Copy link
Member

Pratyush commented Apr 5, 2020

All elliptic curves in Zexe already work with the pippenger-based MSM!

burdges referenced this issue in w3f/ring-vrf Apr 5, 2020
@Pratyush
Copy link
Member

Hmm @jon-chuang do you know what the difference between the two algorithms was? I believe ark-ec is just using the standard EFD algorithms

@Pratyush Pratyush transferred this issue from arkworks-rs/snark Nov 20, 2020
@Pratyush Pratyush added the T-performance Type: performance improvements label Nov 20, 2020
@jon-chuang
Copy link
Contributor Author

jon-chuang commented Nov 21, 2020

Well certainly with w-NAF and GLV we've achieved the desired speedup for scalar mul and more. The only remaining question is for the mixed add.

Wrt your question, I don't know.

@ValarDragon
Copy link
Member

AFAIU, gnark has a lower finite field multiplication time than arkworks, due to the optimization to montgomery reduction they describe in this article: https://hackmd.io/@zkteam/modular_multiplication#Implementation. Their speedup was 65ns -> 50ns per multiplication, which looks roughly like the speedup for mul_assign.

(Perhaps theres a separate algorithmic speedup there as well)

@jon-chuang
Copy link
Contributor Author

This is incorrect, the above discrepancies were even after the equivalent alg was implemented. In fact, our assembly montgomery mul is faster.

Anw, I'm closing, as these comments are imo based on old data and not worth digging up. If someone wants to bench carefully and find areas for improvements please do so anew.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
T-performance Type: performance improvements
Projects
None yet
Development

No branches or pull requests

4 participants