-
Notifications
You must be signed in to change notification settings - Fork 6
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
Simplify debug naming of variables in constraints #435
base: master
Are you sure you want to change the base?
Conversation
query_instance
's API
I would say this change definitely worth to explore as we always looking for improve the readibility. But honestly wrapping them in And we can expect it might be help to make binary size smaller if we gonna distribute prover binary into IOT device. So I would suggest before clear out the thoughts, please on hold this issue and spend effort on other more urgent milestone task. We definitely look back into this issue sometime, and prove we can achieve same effect without "closure" then it will be super nice |
Closures aren't free to create and pass around, even if you don't use them. Yes, a clever optimizing compiler can perhaps remove them, but the same techniques would allow the compiler also remove the
Well, the PR branch has about 3% smaller binary sizes than what's currently in This is PR mainly for readability, and to avoid our typical cargo culting and tendency to unnecessarily overcomplicate things. |
Instead of passing an
FnOnce
closure with no arguments, we just pass the name itself.It looks like we copied the old convention from other R1CS proving systems like bellman. But we always execute our closure, rendering the whole exercise pointless, while they only do execute theirs in debug contexts. (Thanks to Ming for the historic context!)
(And even for bellman, it's unlikely they actually get anything out of the extra complexity: making and passing closures around is a lot of work at runtime. And an optimising compiler that can remove an unused closure can also much easier remove an unused string.)
I ran some benchmarks. The change ever so slightly speeds up compilation and runtime, and decreases the size of our binaries.
On
master
:On this branch:
This benchmark is just for fun, the PR is for readability.