Evaluating Compiler Optimization Impacts on zkVM Performance
Thomas Gassmann, Stefanos Chaliasos, Thodoris Sotiropoulos, Zhendong Su
TL;DR
This paper delivers the first systematic investigation of how traditional LLVM compiler optimizations affect zkVM performance, addressing the mismatch between CPU-centric assumptions and the proof-centric cost model of zkVMs. By evaluating 64 passes, six optimization levels, and 58 benchmarks across two RISC-V zkVMs, the authors show that standard -O3 gains exceed 40% but are smaller than on x86, due to hardware-oriented heuristics that do not transfer to zkVMs. A fine-grained pass-level analysis identifies inlining as generally beneficial and LICM as often harmful, with paging pressure and dynamic instruction count emerging as primary cost drivers; modest, zkVM-aware refinements yield up to 45% execution improvements and consistent proof-time gains. Moreover, autotuning with OpenTuner can surpass -O3 by up to 2.2x in cycle count on several benchmarks, illustrating a practical path to further zkVM performance improvements and motivating future zkVM-specific backends and passes.
Abstract
Zero-knowledge proofs (ZKPs) are the cornerstone of programmable cryptography. They enable (1) privacy-preserving and verifiable computation across blockchains, and (2) an expanding range of off-chain applications such as credential schemes. Zero-knowledge virtual machines (zkVMs) lower the barrier by turning ZKPs into a drop-in backend for standard compilation pipelines. This lets developers write proof-generating programs in conventional languages (e.g., Rust or C++) instead of hand-crafting arithmetic circuits. However, these VMs inherit compiler infrastructures tuned for traditional architectures rather than for proof systems. In particular, standard compiler optimizations assume features that are absent in zkVMs, including cache locality, branch prediction, or instruction-level parallelism. Therefore, their impact on proof generation is questionable. We present the first systematic study of the impact of compiler optimizations on zkVMs. We evaluate 64 LLVM passes, six standard optimization levels, and an unoptimized baseline across 58 benchmarks on two RISC-V-based zkVMs (RISC Zero and SP1). While standard LLVM optimization levels do improve zkVM performance (over 40\%), their impact is far smaller than on traditional CPUs, since their decisions rely on hardware features rather than proof constraints. Guided by a fine-grained pass-level analysis, we~\emph{slightly} refine a small set of LLVM passes to be zkVM-aware, improving zkVM execution time by up to 45\% (average +4.6\% on RISC Zero, +1\% on SP1) and achieving consistent proving-time gains. Our work highlights the potential of compiler-level optimizations for zkVM performance and opens new direction for zkVM-specific passes, backends, and superoptimizers.
