Skip to content

Comments

Prototype: Approximate full circuit effectiveness#3588

Draft
georgwiese wants to merge 18 commits intomainfrom
copilot/compute-circuit-effectiveness
Draft

Prototype: Approximate full circuit effectiveness#3588
georgwiese wants to merge 18 commits intomainfrom
copilot/compute-circuit-effectiveness

Conversation

@georgwiese
Copy link
Collaborator

@georgwiese georgwiese commented Jan 27, 2026

In the context of branch prediction (#3455), I was curious about the following: If we compiled the entire execution into one giant circuit, what would the effectiveness be? This is an upper limit of what we can hope branch prediction to achieve.

Algorithm

This PR estimates this as follows:

  • Given a program and input, it executes the program, collecting all PCs. This results in millions of instructions in practice.
  • Then it chunks it into chunks of a given size.
    • Note: We also split chunks when we reach a disallowed instruction (typically a manual precompile) or a phantom instruction (which I'm not sure why it exists, but somehow it skips a PC when it reaches one).
  • It samples 1,000 chunks (weighted by the number of instructions in the chunk) and feeds the sequence of instructions as a "basic block" to autoprecompiles::build.
  • Finally, it computes the aggregated effectiveness of all the APCs.

In the limit (chunk size → ∞), this converges to compiling the entire computation into one circuit.

Running the code

This is an example:

cargo run -p cli-openvm -r -- get-full-circuit-effectiveness guest-keccak --input 1 --chunk-size 10

Results on reth

I also integrated this into our OpenVM reth benchmark (powdr-labs/openvm-reth-benchmark#56) and ran the code on Ethereum block 24171377(3.28x effectiveness on nightly)

These are the results:

Chunk size 10

Chunked execution into 20180568 chunks of up to 10 instructions each
Chunk size summary:
  1-1 instructions: 109132
  2-2 instructions: 82994
  3-3 instructions: 5302
  4-4 instructions: 253085
  5-5 instructions: 9677
  6-6 instructions: 8388
  7-7 instructions: 4418
  8-8 instructions: 35364
  9-9 instructions: 4277
  10-10 instructions: 19667931
Selecting up to 1000 chunks randomly...
Processing chunks in parallel...
=== Full Circuit Effectiveness ===
Total instructions: 198998122
Software trace cells: 849,667
APC trace cells: 254,329
Effectiveness: 3.34x
==================================

Chunk size 100

Chunked execution into 2438185 chunks of up to 100 instructions each
Chunk size summary:
  1-10 instructions: 196927
  11-20 instructions: 286440
  21-30 instructions: 5112
  31-40 instructions: 7477
  41-50 instructions: 4138
  51-60 instructions: 3686
  61-70 instructions: 4434
  71-80 instructions: 2806
  81-90 instructions: 2425
  91-100 instructions: 1924740
Selecting up to 1000 chunks randomly...
Processing chunks in parallel...
=== Full Circuit Effectiveness ===
Total instructions: 198998122
Software trace cells: 8,371,640
APC trace cells: 1,450,345
Effectiveness: 5.77x
==================================

Chunk size 1000

Chunked execution into 693235 chunks of up to 1000 instructions each
Chunk size summary:
  1-100 instructions: 482302
  101-200 instructions: 4804
  201-300 instructions: 4044
  301-400 instructions: 2882
  401-500 instructions: 3140
  501-600 instructions: 8777
  601-700 instructions: 3057
  701-800 instructions: 3611
  801-900 instructions: 2214
  901-1000 instructions: 178404
Selecting up to 1000 chunks randomly...
Processing chunks in parallel...
=== Full Circuit Effectiveness ===
Total instructions: 198998122
Software trace cells: 80,382,009
APC trace cells: 11,114,803
Effectiveness: 7.23x
==================================

Copilot AI and others added 18 commits January 21, 2026 18:39
Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
…ailing whitespace

Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
…mpirical constraints, change filter_map to filter+unwrap, panic on missing PC

Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
Co-authored-by: georgwiese <1701960+georgwiese@users.noreply.github.com>
@georgwiese georgwiese requested a review from pacheco January 27, 2026 15:59
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