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

In-place cloning of Montgomery form #566

Closed
wants to merge 1 commit into from

Conversation

xuganyu96
Copy link
Contributor

Originally meant to allow boxed Monty to be cloned without additional allocation. Also includes a change to the Monty trait to expose clone_from_montgomery to generics

@tarcieri
Copy link
Member

Why not just use Clone::clone_from?

@xuganyu96
Copy link
Contributor Author

Why not just use Clone::clone_from?

My bad for not realizing that the option is here.

@xuganyu96 xuganyu96 closed this Jan 27, 2024
@tarcieri
Copy link
Member

Note that the implementation of clone_from isn't quite in-place yet the way this PR was.

We'd need to deal with mismatched numbers of limbs to make it work like what you had (in which case panicking is probably fine, so clone_from doesn't have weird performance edge cases)

@xuganyu96
Copy link
Contributor Author

Note that the implementation of clone_from isn't quite in-place yet the way this PR was.

We'd need to deal with mismatched numbers of limbs to make it work like what you had (in which case panicking is probably fine, so clone_from doesn't have weird performance edge cases)

I originally raised this PR because of entropyxyz/crypto-primes#41, in which fjarri mentioned the Lucas testing having a lot of .clone() calls. After running a cargo flamegraph, however, I found that the bulk of the time of generating prime is spent on instantiating MontyForm so maybe allocating is not the bottleneck there.

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