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

feat: reduce the number unconstrained boundary hops in bloblib #10603

Merged
merged 18 commits into from
Dec 12, 2024

Conversation

TomAFrench
Copy link
Member

I've taken a quick look through the bloblib to see if we can make any optimizations on the Noir code itself. This PR has a few changes from this:

  • I've removed the usage of std::as_witness as all the usage was applied to the return values from unconstrained functions (and so will be witnesses anyway).
    • This shouldn't have affected performance but it also wasn't providing us with any benefits.
  • Rather than calling many unconstrained functions from a constrained function I have created unconstrained helpers which will perform all calculations and then return any values which are necessary for applying constraints.
    • This minimises the amount of data which gets pushed from the ACVM to the Brillig VM and vice versa. This is important as we no longer need to read all of arguments from calldata and cast them to the correct types or arrange the results in memory to be read back into the main witness map by the ACVM.
    • This means that for the calculation of a single partial_sum, we would have to spin up and tear down the brillig VM 17(!) times whereas now it will be done just once.
  • I've removed some cases were we'd use BigNum::evaluate_quadratic_expression in order to perform simple arithmetic and replaced them with the equivalent constrained operation. An example for this is calculating z_pow_d.

Copy link
Contributor

github-actions bot commented Dec 11, 2024

Changes to circuit sizes

Generated at commit: 5a28753866b7b872006362aa263e2bc54c344388, compared to commit: 0332bb8893a880e3c05869b26ae45699ac3876c7

🧾 Summary (100% most significant diffs)

Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_block_root -50,688 ✅ -6.92% 0 ➖ 0.00%

Full diff report 👇
Program ACIR opcodes (+/-) % Circuit size (+/-) %
rollup_block_root 682,326 (-50,688) -6.92% 4,404,486 (0) 0.00%

@TomAFrench
Copy link
Member Author

@MirandaWood looks like this is fixed now.

@MirandaWood MirandaWood merged commit e8685ac into mw/blob-circuit-2 Dec 12, 2024
46 checks passed
@MirandaWood MirandaWood deleted the tf/reduce-constrained-boundary-jumps branch December 12, 2024 17:54
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