Skip to content

feat: Lazily call setup function for moduli and curves on first use #1603

New issue

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

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

Already on GitHub? # to your account

Merged
merged 15 commits into from
Apr 29, 2025

Conversation

Avaneesh-axiom
Copy link
Contributor

@Avaneesh-axiom Avaneesh-axiom commented Apr 25, 2025

We no longer need to manually call setup_* at the start of main for the moduli and curves. Instead, setup is automatically done on first use of each modulus or curve.

Depends on #1596

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

@Avaneesh-axiom Avaneesh-axiom marked this pull request as ready for review April 25, 2025 16:57
@Avaneesh-axiom Avaneesh-axiom force-pushed the feat/lazy-setup branch 2 times, most recently from a6a58ae to 438d810 Compare April 25, 2025 21:36
@Avaneesh-axiom Avaneesh-axiom changed the base branch from main to feat/binding-primitive-libs April 25, 2025 21:39

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

setup_all_moduli();
setup_all_complex_extensions();
setup_all_curves();
// TODO: Since we don't explicitly call setup functions anymore, we should rewrite this test
Copy link
Contributor

Choose a reason for hiding this comment

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

don't forget this TODO before we merge feature branch

This comment has been minimized.

@@ -110,6 +113,7 @@ pub fn complex_declare(input: TokenStream) -> TokenStream {
}
#[cfg(target_os = "zkvm")]
{
Self::assert_is_setup();
Copy link
Contributor

Choose a reason for hiding this comment

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

side comment, technically shouldn't it be assert_is_set_up? not worth changing though

Copy link
Contributor Author

Choose a reason for hiding this comment

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

yes

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

This comment has been minimized.

Copy link
Contributor

@jonathanpwang jonathanpwang left a comment

Choose a reason for hiding this comment

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

LGTM, I cleaned up the macros a bit so they are safer for no_mangle and also conform to the other extern functions better.

Copy link

group app.proof_time_ms app.cycles app.cells_used leaf.proof_time_ms leaf.cycles leaf.cells_used
verify_fibair (-24 [-1.9%]) 1,270 333,953 17,675,030 - - -
fibonacci_program (-23 [-0.8%]) 2,703 1,500,277 50,589,503 - - -
regex_program (+56 [+0.7%]) 8,092 4,165,226 166,511,152 - - -
ecrecover_program (-4 [-0.3%]) 1,445 (+20412 [+7.1%]) 309,859 (+672913 [+4.7%]) 15,143,099 - - -
pairing (+51 [+1.0%]) 4,977 (+36796 [+2.0%]) 1,857,232 (+1223114 [+1.3%]) 97,055,521 - - -

Commit: b39fd2e

Benchmark Workflow

@jonathanpwang jonathanpwang merged commit a8df155 into feat/binding-primitive-libs Apr 29, 2025
20 checks passed
@jonathanpwang jonathanpwang deleted the feat/lazy-setup branch April 29, 2025 03:09
# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants