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

Speed up RandomPolynomial by a factor 13 #27

Merged
merged 2 commits into from
Jun 14, 2020

Conversation

greatroar
Copy link

@greatroar greatroar commented Mar 12, 2020

The first commit avoids having to do the multiplication twice and speeds up Pol.Irreducible:

name              old time/op  new time/op  delta
PolIrreducible-8  62.4ms ± 0%  57.4ms ± 0%  -8.11%  (p=0.000 n=10+10)

The second introduces a fast path for Pol.Mul(x, 2), for a combined speedup of:

name                old time/op  new time/op  delta
RandomPolynomial-8   102ms ±13%     8ms ± 8%  -92.55%  (p=0.000 n=10+10)
PolIrreducible-8    62.4ms ± 0%   4.3ms ± 0%  -93.04%  (p=0.000 n=10+7)

greatroar added 2 commits March 12, 2020 14:33
This avoids having to do the multiplication twice and speeds up
Pol.Irreducible:

name              old time/op  new time/op  delta
PolIrreducible-8  62.4ms ± 0%  57.4ms ± 0%  -8.11%  (p=0.000 n=10+10)
Benchmark results on amd64 show a 13-fold speedup:

name              old time/op  new time/op  delta
PolIrreducible-8  57.4ms ± 0%   4.3ms ± 0%  -92.43%  (p=0.000 n=10+7)

The mul2 call could be inlined in Pol.MulMod for a further 7% speedup,
but the tests don't cover that.

Compared to 3404fc8, we have:

name                old time/op  new time/op  delta
RandomPolynomial-8   102ms ±13%     8ms ± 8%  -92.55%  (p=0.000 n=10+10)
PolIrreducible-8    62.4ms ± 0%   4.3ms ± 0%  -93.04%  (p=0.000 n=10+7)
@greatroar greatroar changed the title Inline overflow check in Pol.Mul Speed up RandomPolynomial by a factor 13 Mar 13, 2020
Copy link
Member

@MichaelEischer MichaelEischer left a comment

Choose a reason for hiding this comment

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

LGTM. Thanks.

@MichaelEischer MichaelEischer merged commit b7c173c into restic:master Jun 14, 2020
@greatroar greatroar deleted the fast-mul branch June 17, 2020 12:16
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.

None yet

2 participants