Skip to content

feat(ssa): Limit the number of steps executed by the SSA interpreter during constant folding#10481

Merged
asterite merged 7 commits intomasterfrom
af/9006-const-fold-limit
Nov 12, 2025
Merged

feat(ssa): Limit the number of steps executed by the SSA interpreter during constant folding#10481
asterite merged 7 commits intomasterfrom
af/9006-const-fold-limit

Conversation

@aakoshh
Copy link
Contributor

@aakoshh aakoshh commented Nov 11, 2025

Description

Problem

Resolves #9006

Summary

  • Add InterpreterOptions::step_limit to optionally limit the number of instructions (including terminator instructions) the interpreter is allowed to execute.
  • Add Interpreter::step_counter which is incremented with each executed instruction; if we reach the step_limit it returns InterpreterError::OutOfBudget.
  • Add Interpreter::reset_step_counter to reset the counter to 0 between calls to entry points, since we are reusing the interpreter instance during constant folding.
  • Limit the step count during fold_constants_with_brillig to 10M, which on my laptop ran a tight loop for ~100ms.
  • Add --step-limit in the interpret CLI commands

Additional Context

When the ticket was made, it was about Brillig VM, but since then we switched to using the SSA interpreter for constant folding.

This PR leaves the Brillig VM untouched, but we can still use #9007 to limit the steps taken by the VM itself during execute.

User Documentation

Check one:

  • No user documentation needed.
  • Changes in docs/ included in this PR.
  • [For Experimental Features] Changes in docs/ 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.

@aakoshh aakoshh requested a review from a team November 11, 2025 20:36
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 'Execution Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
rollup-checkpoint-merge 0.004 s 0.003 s 1.33
sha512-100-bytes 0.083 s 0.047 s 1.77

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

CC: @TomAFrench

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 'Compilation Time'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: d6f9674 Previous: fd27764 Ratio
private-kernel-reset 10.584 s 7.616 s 1.39

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

CC: @TomAFrench

@aakoshh aakoshh added the bench-show Display benchmark results on PR label Nov 11, 2025
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: faaa945 Previous: fd27764 Ratio
test_report_zkpassport_noir-ecdsa_ 3 s 2 s 1.50

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

CC: @TomAFrench

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.

ACVM Benchmarks

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
purely_sequential_opcodes 259605 ns/iter (± 673) 255057 ns/iter (± 316) 1.02
perfectly_parallel_opcodes 230943 ns/iter (± 1762) 231220 ns/iter (± 3966) 1.00
perfectly_parallel_batch_inversion_opcodes 2783987 ns/iter (± 2357) 2259283 ns/iter (± 826) 1.23

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

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 'ACVM Benchmarks'.
Benchmark result of this commit is worse than the previous benchmark result exceeding threshold 1.20.

Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
perfectly_parallel_batch_inversion_opcodes 2783987 ns/iter (± 2357) 2259283 ns/iter (± 826) 1.23

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

CC: @TomAFrench

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.

Test Suite Duration

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
test_report_AztecProtocol_aztec-packages_noir-projects_aztec-nr 116 s 114 s 1.02
test_report_AztecProtocol_aztec-packages_noir-projects_noir-contracts 154 s 156 s 0.99
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_blob 373 s 415 s 0.90
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_private-kernel-lib 293 s 277 s 1.06
test_report_AztecProtocol_aztec-packages_noir-projects_noir-protocol-circuits_crates_types 110 s 115 s 0.96
test_report_noir-lang_noir-bignum_ 159 s 155 s 1.03
test_report_noir-lang_noir_bigcurve_ 339 s 321 s 1.06
test_report_noir-lang_sha256_ 16 s 16 s 1
test_report_noir-lang_sha512_ 14 s 13 s 1.08
test_report_zkpassport_noir-ecdsa_ 2 s 2 s 1
test_report_zkpassport_noir_rsa_ 1 s 1 s 1

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

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.

Opcode count

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
private-kernel-inner 18023 opcodes 18023 opcodes 1
private-kernel-reset 80613 opcodes 80613 opcodes 1
private-kernel-tail 7209 opcodes 7209 opcodes 1
rollup-block-root-first-empty-tx 1100 opcodes 1100 opcodes 1
rollup-block-root-single-tx 876 opcodes 876 opcodes 1
rollup-block-root 2253 opcodes 2253 opcodes 1
rollup-checkpoint-merge 2132 opcodes 2132 opcodes 1
rollup-checkpoint-root-single-block 1919761 opcodes 1919761 opcodes 1
rollup-checkpoint-root 1921135 opcodes 1921135 opcodes 1
rollup-root 2607 opcodes 2607 opcodes 1
rollup-tx-base-private 306830 opcodes 306830 opcodes 1
rollup-tx-base-public 262449 opcodes 262449 opcodes 1
rollup-tx-merge 1485 opcodes 1485 opcodes 1
semaphore-depth-10 5699 opcodes 5699 opcodes 1
sha512-100-bytes 13173 opcodes 13173 opcodes 1

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

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.

Execution Time

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
private-kernel-inner 0.014 s 0.014 s 1
private-kernel-reset 0.212 s 0.206 s 1.03
private-kernel-tail 0.008 s 0.008 s 1
rollup-block-root-first-empty-tx 0.003 s 0.003 s 1
rollup-block-root-single-tx 0.003 s 0.003 s 1
rollup-block-root 0.004 s 0.004 s 1
rollup-checkpoint-merge 0.004 s 0.003 s 1.33
rollup-checkpoint-root-single-block 24.1 s 23.2 s 1.04
rollup-checkpoint-root 23.3 s 23.1 s 1.01
rollup-root 0.004 s 0.004 s 1
rollup-tx-base-private 0.338 s 0.339 s 1.00
rollup-tx-base-public 0.266 s 0.262 s 1.02
rollup-tx-merge 0.002 s 0.002 s 1
semaphore-depth-10 0.009 s 0.009 s 1
sha512-100-bytes 0.083 s 0.047 s 1.77

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

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.

Compilation Time

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
private-kernel-inner 1.9 s 1.978 s 0.96
private-kernel-reset 7.69 s 7.656 s 1.00
private-kernel-tail 1.752 s 1.754 s 1.00
rollup-block-root-first-empty-tx 1.41 s 1.356 s 1.04
rollup-block-root-single-tx 1.4 s 1.38 s 1.01
rollup-block-root 1.45 s 1.44 s 1.01
rollup-checkpoint-merge 1.396 s 1.394 s 1.00
rollup-checkpoint-root-single-block 410 s 407 s 1.01
rollup-checkpoint-root 399 s 412 s 0.97
rollup-root 1.484 s 1.566 s 0.95
rollup-tx-base-private 20.6 s 22.3 s 0.92
rollup-tx-base-public 83.42 s 85.16 s 0.98
rollup-tx-merge 1.324 s 1.342 s 0.99
semaphore-depth-10 0.789 s 0.781 s 1.01
sha512-100-bytes 1.649 s 1.533 s 1.08

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

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.

Artifact Size

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
private-kernel-inner 754.1 KB 754.1 KB 1
private-kernel-reset 2067.7 KB 2067.7 KB 1
private-kernel-tail 440.1 KB 440.1 KB 1
rollup-block-root-first-empty-tx 200.4 KB 200.4 KB 1
rollup-block-root-single-tx 200.8 KB 200.8 KB 1
rollup-block-root 281.1 KB 281.1 KB 1
rollup-checkpoint-merge 359.9 KB 359.9 KB 1
rollup-checkpoint-root-single-block 51639.4 KB 51639.4 KB 1
rollup-checkpoint-root 51679.2 KB 51679.2 KB 1
rollup-root 391.9 KB 391.9 KB 1
rollup-tx-base-private 5617.5 KB 5617.5 KB 1
rollup-tx-base-public 4881.8 KB 4881.8 KB 1
rollup-tx-merge 179.5 KB 179.5 KB 1
semaphore-depth-10 570.9 KB 570.9 KB 1
sha512-100-bytes 506.3 KB 506.3 KB 1

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

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.

Compilation Memory

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
private-kernel-inner 267.87 MB 267.87 MB 1
private-kernel-reset 494.37 MB 494.37 MB 1
private-kernel-tail 237.49 MB 237.49 MB 1
rollup-block-root-first-empty-tx 334.39 MB 334.39 MB 1
rollup-block-root-single-tx 332.83 MB 332.83 MB 1
rollup-block-root 335.62 MB 335.6 MB 1.00
rollup-checkpoint-merge 335.58 MB 335.58 MB 1
rollup-checkpoint-root-single-block 11250 MB 11250 MB 1
rollup-checkpoint-root 11250 MB 11250 MB 1
rollup-root 337.13 MB 337.13 MB 1
rollup-tx-base-private 1070 MB 1070 MB 1
rollup-tx-base-public 3030 MB 3030 MB 1
rollup-tx-merge 332.41 MB 332.41 MB 1
semaphore_depth_10 92.33 MB 92.33 MB 1
sha512_100_bytes 185.7 MB 185.67 MB 1.00

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

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.

Execution Memory

Details
Benchmark suite Current: 618b8a4 Previous: 975ef74 Ratio
private-kernel-inner 257.45 MB 257.45 MB 1
private-kernel-reset 290.85 MB 290.85 MB 1
private-kernel-tail 237.91 MB 237.91 MB 1
rollup-block-root 333.73 MB 333.73 MB 1
rollup-checkpoint-merge 332.48 MB 332.48 MB 1
rollup-checkpoint-root-single-block 1760 MB 1760 MB 1
rollup-checkpoint-root 1760 MB 1760 MB 1
rollup-root 333.71 MB 333.71 MB 1
rollup-tx-base-private 521.17 MB 521.17 MB 1
rollup-tx-base-public 467.65 MB 467.65 MB 1
rollup-tx-merge 331.94 MB 331.94 MB 1
semaphore_depth_10 73.85 MB 73.85 MB 1
sha512_100_bytes 72.09 MB 72.09 MB 1

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

Copy link
Collaborator

@asterite asterite left a comment

Choose a reason for hiding this comment

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

Looks great!

@asterite asterite added this pull request to the merge queue Nov 12, 2025
Merged via the queue into master with commit 6f0c090 Nov 12, 2025
132 checks passed
@asterite asterite deleted the af/9006-const-fold-limit branch November 12, 2025 14:27
github-merge-queue bot pushed a commit to AztecProtocol/aztec-packages that referenced this pull request Nov 13, 2025
Automated pull of nightly from the
[noir](https://github.com/noir-lang/noir) programming language, a
dependency of Aztec.
BEGIN_COMMIT_OVERRIDE
chore: remove `local_annotations` from flattening
(noir-lang/noir#10483)
chore: better error recovery for multiple mut in pattern
(noir-lang/noir#10490)
chore(frontend): Tuple pattern tests and remove confusing arity error
(noir-lang/noir#10480)
chore: monomorphizer public fields
(noir-lang/noir#9979)
chore: remove a bunch of dummy definitions
(noir-lang/noir#10482)
feat(ssa): Limit the number of steps executed by the SSA interpreter
during constant folding (noir-lang/noir#10481)
fix: remove saturation from loop bound increments
(noir-lang/noir#10479)
fix(print): Print enums (noir-lang/noir#10472)
fix(frontend): No negative overflow when quoting signed integer
(noir-lang/noir#10331)
chore: green light Brillig for audit
(noir-lang/noir#10376)
END_COMMIT_OVERRIDE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

bench-show Display benchmark results on PR

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Compiler hangs: infinite loop in Inlining Brillig Calls

2 participants