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

chore: mitigate copies in final_exponentiation #12

Merged
merged 1 commit into from
May 16, 2024
Merged

chore: mitigate copies in final_exponentiation #12

merged 1 commit into from
May 16, 2024

Conversation

arthurpaulino
Copy link
Member

@arthurpaulino arthurpaulino commented May 16, 2024

This PR applies the techniques from #11 in order to further reduce copying in the hot path of pairing.

@arthurpaulino arthurpaulino force-pushed the ap/no-copy branch 11 times, most recently from 4ceb00f to 9d6f045 Compare May 16, 2024 18:31
@arthurpaulino arthurpaulino changed the title Removing more copies chore: mitigate copies in final_exponentiation May 16, 2024
@arthurpaulino arthurpaulino marked this pull request as ready for review May 16, 2024 18:44
src/fp6.rs Outdated Show resolved Hide resolved
src/fp6.rs Outdated Show resolved Hide resolved
@arthurpaulino
Copy link
Member Author

@wwared I've deleted Fp6::mul_inp and instead did a small optimization in Fp6::mul_interleaved that resulted in a cheap drop of 100k cycles

@arthurpaulino arthurpaulino requested a review from wwared May 16, 2024 19:49
Copy link
Member

@huitseeker huitseeker left a comment

Choose a reason for hiding this comment

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

This looks great, but it includes a lot of APIs that are essentially one & away from the original. I wonder: how hard would it be to write tests for those functions comparing them to the original?

IOW:

const TEST_CASES: usize = 100;

#[test]
fn test_foo() {
  for _i in 0..TEST_CASES {
    let a = Input::random();
    let b = Input::random();
    assert_eq!(foo(a.clone(), b), foo_inp(&mut a, &b));
  }
}

?

@wwared
Copy link
Member

wwared commented May 16, 2024

@huitseeker: Opened issue #13 to track this, I think it shouldn't be too hard (requires to be careful around the functions that got cfg'd out of the zkvm), but we definitely want to do this

@wwared wwared merged commit b052a66 into zkvm May 16, 2024
18 checks passed
@wwared wwared deleted the ap/no-copy branch May 16, 2024 21:34
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.

3 participants