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

Pairing: remove preCompute and go routines in MillerLoop #27

Merged
merged 5 commits into from
Jan 11, 2021

Conversation

gbotrel
Copy link
Collaborator

@gbotrel gbotrel commented Jan 8, 2021

@yelhousni following your recent awesome PR (#26) did some experiments and benchmarks on various architectures (x64), that confirms that for a small number of pair of points in the Pairing function, there is a severe penalty (specifically on amd platforms).

In this PR, I just removed the go routines, the multiple [68]lineEvaluation (replace by a single lineEvaluation object) and merged the preCompute loop within the line evaluation / result compute loop. Did on bn256 and bls381.

** If we want to deal with large number of pairs in Pairing, then we should probably revisit the preCompute strategy **

Here is where we're at on our reference benchmark (running on AWS z1d.3xlarge instance, with hyperthreading disabled) :

mcl(ns/op) gurvy(ns/op)
Pairing(bn256) 478244 489258
Pairing(bls381) 676513 707984

For the before/after removal of go routines and precompute:

on AMD Ryzen 3700X, bn256 and bls381:

benchmark                  old ns/op     new ns/op     delta
BenchmarkPairing-16        717847        429341        -40.19%
BenchmarkMillerLoop-16     330055        209102        -36.65%
benchmark                  old ns/op     new ns/op     delta
BenchmarkPairing-16        1156689       644036        -44.32%
BenchmarkMillerLoop-16     517074        308647        -40.31%

on Intel MBP, less conclusive but not too bad:

benchmark                 old ns/op     new ns/op     delta
BenchmarkPairing-8        561681        546137        -2.77%
BenchmarkMillerLoop-8     253963        263012        +3.56%

Copy link
Collaborator

@yelhousni yelhousni left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

bn256/pairing.go Outdated Show resolved Hide resolved
@yelhousni
Copy link
Collaborator

yelhousni commented Jan 11, 2021

@gbotrel In the last commit, I applied the same changes to bls377.

@gbotrel gbotrel merged commit 476370d into develop Jan 11, 2021
@gbotrel gbotrel deleted the experimental/pairing branch January 11, 2021 15:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants