risc0 icon indicating copy to clipboard operation
risc0 copied to clipboard

Discrepancy in proving time between near-identical binaries

Open thomasgassmann opened this issue 9 months ago • 1 comments

Is there an existing issue?

  • [x] I have searched the existing issues

Experiencing problems? Have you tried our Discord first?

  • [x] This is not a support question.

Description of bug

I have two ELF-binaries I'm proving with risc0, both resulting from the same source code and the same flags, but built on different machines. However one of these binaries consistently takes only about half of the time to prove.

The example program to be proven is largely based on this benchmarking application here, the two ELF files are here and here. Both of these binaries were built as follows:

CC=gcc CC_riscv32im_risc0_zkvm_elf=~/.risc0/cpp/bin/riscv32-unknown-elf-gcc \
    RUSTFLAGS="-C opt-level=0 -C no-prepopulate-passes -C passes=loweratomic -C link-arg=-Ttext=0x00200800 -C panic=abort" \
    RISC0_FEATURE_bigint2=1 \
    cargo +risc0 build --release \
        --target riscv32im-risc0-zkvm-elf --manifest-path Cargo.toml --features risc0

Measuring the proving time consistently yields that b proves about twice as fast as a. Both programs also have the exact same number of cycles. I also did some preliminary profiling which indicated that risc0 spends a lot more time in risc0_zkp::core::ntt::fwd_butterfly_xx. (repository to reproduce here)

Steps to reproduce

  1. git clone https://github.com/thomasgassmann/risc0-fibonacci/
  2. cd risc0-fibonacci/prove
  3. cargo run --release

thomasgassmann avatar Mar 19 '25 22:03 thomasgassmann