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

fix(ssa): Use number of SSA instructions for the Brillig unrolling bytecode size limit #7242

Merged
merged 4 commits into from
Jan 31, 2025

Conversation

vezenovm
Copy link
Contributor

Description

Problem*

Pulls a change out of #7236 that was causing panics with less aggressive inliner settings. Comment for reference: #7236 (comment).

I labelled this PR a fix rather than a chore as it does prevent possible panics.

Summary*

After performing an unroll in the Brillig runtime we have a setting that lets us set an upper bound on the bytecode size increase percentage. However, we have certain intrinsics (e.g. DerivePedersenGenerators) that we expect to entirely compile-time and fully resolved by Brillig gen.

Another possible fix would be to set any method which calls derive_generators (such as pedersen_hash_with_separator) as #[inline_always]. However, we still do not have a guarantee that the separator has been resolved to a constant. Let's say we know derive_generators is called by pedersen_hash_with_separator. Even if pedersen_hash_with_separator is always inlined into its parent we cannot guarantee that the input for the separator comes from the parent's function parameter. This issue will exist with any other intrinsics we expect to be fully resolved by compile-time.

By using the number of SSA instructions we can also avoid the extra compilation to Brillig as well as having to expose extra Brillig gen logic to the SSA passes. This gives us a better separation of concerns.

Additional Context

Documentation*

Check one:

  • No documentation needed.
  • Documentation included in this PR.
  • [For Experimental Features] Documentation to be submitted in a separate PR.

PR Checklist*

  • I have tested the changes locally.
  • I have formatted the changes with Prettier and/or cargo fmt on default settings.

Copy link
Contributor

@github-actions github-actions bot left a comment

Choose a reason for hiding this comment

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

⚠️ Performance Alert ⚠️

Possible performance regression was detected for benchmark 'Test Suite Duration'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: f6bf769 Previous: 15bbaa8 Ratio
noir-lang_schnorr_ 1 s 0 s +∞
noir-lang_noir_check_shuffle_ 1 s 0 s +∞
noir-lang_mimc_ 1 s 0 s +∞

This comment was automatically generated by workflow using github-action-benchmark.

CC: @TomAFrench

@TomAFrench TomAFrench enabled auto-merge January 31, 2025 11:45
Copy link
Contributor

@jfecher jfecher left a comment

Choose a reason for hiding this comment

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

This seems much simpler than going off of brillig instructions

@TomAFrench TomAFrench added this pull request to the merge queue Jan 31, 2025
Merged via the queue into master with commit 8d39337 Jan 31, 2025
100 checks passed
@TomAFrench TomAFrench deleted the mv/unroll-size-limit-w-ssa branch January 31, 2025 14:16
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