From 5ffd849acb3a201ece2caacf28b939584fa95dfa Mon Sep 17 00:00:00 2001 From: benbencik Date: Mon, 1 Jun 2026 16:01:50 +0200 Subject: [PATCH 1/4] perf: add optimized llvm parameters for the zisk target --- Cargo.lock | 74 +++++++++---------- .../zisk/src/rust_rv64ima_customized.rs | 27 ++++++- 2 files changed, 63 insertions(+), 38 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 531e07b0..65b81e55 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1207,7 +1207,7 @@ dependencies = [ [[package]] name = "asm-runner" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "libc", @@ -2504,7 +2504,7 @@ source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.18.0#790f9e28a6 [[package]] name = "circuit" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" [[package]] name = "clang-sys" @@ -3260,7 +3260,7 @@ dependencies = [ [[package]] name = "data-bus" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "zisk-common 0.18.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0)", "zisk-core 0.18.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0)", @@ -4447,7 +4447,7 @@ dependencies = [ [[package]] name = "executor" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "arc-swap", @@ -6026,7 +6026,7 @@ source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.18.0#790f9e28a6 [[package]] name = "lib-c" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" [[package]] name = "lib-float" @@ -6036,7 +6036,7 @@ source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.18.0#790f9e28a6 [[package]] name = "lib-float" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" [[package]] name = "libc" @@ -6377,7 +6377,7 @@ dependencies = [ [[package]] name = "mem-common" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "clap", "fields", @@ -6397,7 +6397,7 @@ dependencies = [ [[package]] name = "mem-planner-cpp" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "mem-common", "proofman-common", @@ -9143,7 +9143,7 @@ dependencies = [ [[package]] name = "precomp-arith-eq" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "ark-bn254", "ark-ff 0.5.0", @@ -9180,7 +9180,7 @@ dependencies = [ [[package]] name = "precomp-arith-eq-384" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -9217,7 +9217,7 @@ dependencies = [ [[package]] name = "precomp-big-int" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "generic-array 0.14.9", @@ -9239,7 +9239,7 @@ dependencies = [ [[package]] name = "precomp-blake2" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "mem-common", @@ -9259,7 +9259,7 @@ dependencies = [ [[package]] name = "precomp-dma" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "generic-array 0.14.9", @@ -9283,7 +9283,7 @@ dependencies = [ [[package]] name = "precomp-keccakf" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "circuit 0.18.0 (git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0)", "fields", @@ -9305,7 +9305,7 @@ dependencies = [ [[package]] name = "precomp-poseidon2" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "mem-common", @@ -9326,7 +9326,7 @@ dependencies = [ [[package]] name = "precomp-sha256f" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "mem-common", @@ -9346,7 +9346,7 @@ dependencies = [ [[package]] name = "precompiles-common" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "mem-common", @@ -9377,7 +9377,7 @@ dependencies = [ [[package]] name = "precompiles-helpers" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "ark-bls12-381", "ark-bn254", @@ -9396,7 +9396,7 @@ dependencies = [ [[package]] name = "precompiles-hints" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "borsh", @@ -10649,7 +10649,7 @@ source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.18.0#790f9e28a6 [[package]] name = "riscv" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" [[package]] name = "riscv-decode" @@ -10715,7 +10715,7 @@ dependencies = [ [[package]] name = "rom-setup" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "blake3", @@ -12073,7 +12073,7 @@ dependencies = [ [[package]] name = "sm-arith" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "num-bigint 0.4.6", @@ -12094,7 +12094,7 @@ dependencies = [ [[package]] name = "sm-binary" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "num-bigint 0.4.6", @@ -12114,7 +12114,7 @@ dependencies = [ [[package]] name = "sm-frequent-ops" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "clap", "fields", @@ -12130,7 +12130,7 @@ dependencies = [ [[package]] name = "sm-main" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "mem-common", @@ -12150,7 +12150,7 @@ dependencies = [ [[package]] name = "sm-mem" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "mem-common", @@ -12171,7 +12171,7 @@ dependencies = [ [[package]] name = "sm-rom" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "asm-runner", @@ -15336,7 +15336,7 @@ dependencies = [ [[package]] name = "zisk-cluster-common" version = "0.1.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "borsh", @@ -15386,7 +15386,7 @@ dependencies = [ [[package]] name = "zisk-common" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "alloy-sol-types", "anyhow", @@ -15435,7 +15435,7 @@ dependencies = [ [[package]] name = "zisk-core" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "elf", "fields", @@ -15460,12 +15460,12 @@ source = "git+https://github.com/0xPolygonHermez/zisk.git?tag=v0.18.0#790f9e28a6 [[package]] name = "zisk-definitions" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" [[package]] name = "zisk-pil" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "fields", "proofman-common", @@ -15478,7 +15478,7 @@ dependencies = [ [[package]] name = "zisk-prover-backend" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "alloy-sol-types", "anyhow", @@ -15515,7 +15515,7 @@ dependencies = [ [[package]] name = "zisk-verifier" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "proofman-verifier", ] @@ -15523,7 +15523,7 @@ dependencies = [ [[package]] name = "ziskemu" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "clap", "data-bus", @@ -15624,7 +15624,7 @@ dependencies = [ [[package]] name = "ziskos-hints" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "anyhow", "bincode 2.0.1", @@ -15711,7 +15711,7 @@ dependencies = [ [[package]] name = "zkvm-interface" version = "0.18.0" -source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#ee1d6fc6587b6aac32a3dfbb29b35e79f1748316" +source = "git+https://github.com/han0110/zisk.git?branch=patch%2Fv0.18.0#c57907f7dbb845482809968948b3f4071018e7f5" dependencies = [ "bindgen 0.72.1", ] diff --git a/crates/compiler/zisk/src/rust_rv64ima_customized.rs b/crates/compiler/zisk/src/rust_rv64ima_customized.rs index 67d1e3e6..ab7d1087 100644 --- a/crates/compiler/zisk/src/rust_rv64ima_customized.rs +++ b/crates/compiler/zisk/src/rust_rv64ima_customized.rs @@ -8,7 +8,32 @@ use crate::Error; const ZISK_TOOLCHAIN: &str = "zisk"; const ZISK_TARGET: &str = "riscv64ima-zisk-zkvm-elf"; -const RUSTFLAGS: &[&str] = &["-C", "passes=lower-atomic"]; +const RUSTFLAGS: &[&str] = &[ + "-C", "passes=lower-atomic", + "-C", "llvm-args=--inline-threshold=4749", + "-C", "llvm-args=--unroll-threshold=378", + "-C", "llvm-args=--memdep-block-number-limit=2510", + "-C", "llvm-args=--memdep-block-scan-limit=98", + "-C", "llvm-args=--jump-threading-threshold=16", + "-C", "llvm-args=--max-speculation-depth=0", + "-C", "llvm-args=--licm-versioning-max-depth-threshold=0", + "-C", "llvm-args=--max-uses-for-sinking=119", + "-C", "llvm-args=--inline-instr-cost=1", + "-C", "llvm-args=--inline-memaccess-cost=1", + "-C", "llvm-args=--inline-call-penalty=12", + "-C", "llvm-args=--available-load-scan-limit=23", + "-C", "llvm-args=--bonus-inst-threshold=5", + "-C", "llvm-args=--max-num-inline-blocks=6", + "-C", "llvm-args=--loop-interchange-threshold=2", + "-C", "llvm-args=--licm-max-num-uses-traversed=24", + "-C", "llvm-args=--early-ifcvt-limit=29", + "-C", "llvm-args=--jump-threading-implication-search-threshold=6", + "-C", "llvm-args=--loop-distribute-scev-check-threshold=0", + "-C", "llvm-args=--loop-load-elimination-scev-check-threshold=7", + "-C", "llvm-args=--max-dependences=6", + "-C", "llvm-args=--max-nested-scalar-reduction-interleave=2", + "-C", "llvm-args=--disable-licm-promotion", +]; /// Compiler for Rust guest program to RV64IMA architecture, using customized /// Rust toolchain of ZisK. From 9c47f18c790ca22828962e0073efeb40ef1e8f4f Mon Sep 17 00:00:00 2001 From: benbencik Date: Tue, 2 Jun 2026 15:48:37 +0200 Subject: [PATCH 2/4] fmt --- .../zisk/src/rust_rv64ima_customized.rs | 72 ++++++++++++------- 1 file changed, 48 insertions(+), 24 deletions(-) diff --git a/crates/compiler/zisk/src/rust_rv64ima_customized.rs b/crates/compiler/zisk/src/rust_rv64ima_customized.rs index ab7d1087..fad0f856 100644 --- a/crates/compiler/zisk/src/rust_rv64ima_customized.rs +++ b/crates/compiler/zisk/src/rust_rv64ima_customized.rs @@ -9,30 +9,54 @@ const ZISK_TOOLCHAIN: &str = "zisk"; const ZISK_TARGET: &str = "riscv64ima-zisk-zkvm-elf"; const RUSTFLAGS: &[&str] = &[ - "-C", "passes=lower-atomic", - "-C", "llvm-args=--inline-threshold=4749", - "-C", "llvm-args=--unroll-threshold=378", - "-C", "llvm-args=--memdep-block-number-limit=2510", - "-C", "llvm-args=--memdep-block-scan-limit=98", - "-C", "llvm-args=--jump-threading-threshold=16", - "-C", "llvm-args=--max-speculation-depth=0", - "-C", "llvm-args=--licm-versioning-max-depth-threshold=0", - "-C", "llvm-args=--max-uses-for-sinking=119", - "-C", "llvm-args=--inline-instr-cost=1", - "-C", "llvm-args=--inline-memaccess-cost=1", - "-C", "llvm-args=--inline-call-penalty=12", - "-C", "llvm-args=--available-load-scan-limit=23", - "-C", "llvm-args=--bonus-inst-threshold=5", - "-C", "llvm-args=--max-num-inline-blocks=6", - "-C", "llvm-args=--loop-interchange-threshold=2", - "-C", "llvm-args=--licm-max-num-uses-traversed=24", - "-C", "llvm-args=--early-ifcvt-limit=29", - "-C", "llvm-args=--jump-threading-implication-search-threshold=6", - "-C", "llvm-args=--loop-distribute-scev-check-threshold=0", - "-C", "llvm-args=--loop-load-elimination-scev-check-threshold=7", - "-C", "llvm-args=--max-dependences=6", - "-C", "llvm-args=--max-nested-scalar-reduction-interleave=2", - "-C", "llvm-args=--disable-licm-promotion", + "-C", + "passes=lower-atomic", + "-C", + "llvm-args=--inline-threshold=4749", + "-C", + "llvm-args=--unroll-threshold=378", + "-C", + "llvm-args=--memdep-block-number-limit=2510", + "-C", + "llvm-args=--memdep-block-scan-limit=98", + "-C", + "llvm-args=--jump-threading-threshold=16", + "-C", + "llvm-args=--max-speculation-depth=0", + "-C", + "llvm-args=--licm-versioning-max-depth-threshold=0", + "-C", + "llvm-args=--max-uses-for-sinking=119", + "-C", + "llvm-args=--inline-instr-cost=1", + "-C", + "llvm-args=--inline-memaccess-cost=1", + "-C", + "llvm-args=--inline-call-penalty=12", + "-C", + "llvm-args=--available-load-scan-limit=23", + "-C", + "llvm-args=--bonus-inst-threshold=5", + "-C", + "llvm-args=--max-num-inline-blocks=6", + "-C", + "llvm-args=--loop-interchange-threshold=2", + "-C", + "llvm-args=--licm-max-num-uses-traversed=24", + "-C", + "llvm-args=--early-ifcvt-limit=29", + "-C", + "llvm-args=--jump-threading-implication-search-threshold=6", + "-C", + "llvm-args=--loop-distribute-scev-check-threshold=0", + "-C", + "llvm-args=--loop-load-elimination-scev-check-threshold=7", + "-C", + "llvm-args=--max-dependences=6", + "-C", + "llvm-args=--max-nested-scalar-reduction-interleave=2", + "-C", + "llvm-args=--disable-licm-promotion", ]; /// Compiler for Rust guest program to RV64IMA architecture, using customized From 720539f1b8cd09e63a7400b11f4901a05ca9cafe Mon Sep 17 00:00:00 2001 From: benbencik Date: Tue, 2 Jun 2026 15:51:54 +0200 Subject: [PATCH 3/4] add ERE_RUSTFLAGS --- crates/dockerized/src/compiler.rs | 1 + crates/util/compile/src/rust.rs | 2 ++ 2 files changed, 3 insertions(+) diff --git a/crates/dockerized/src/compiler.rs b/crates/dockerized/src/compiler.rs index 07343e12..46f2d318 100644 --- a/crates/dockerized/src/compiler.rs +++ b/crates/dockerized/src/compiler.rs @@ -146,6 +146,7 @@ impl Compiler for DockerizedCompiler { .inherit_env("RUST_LOG") .inherit_env("NO_COLOR") .inherit_env("ERE_RUST_TOOLCHAIN") + .inherit_env("ERE_RUSTFLAGS") .volume(&self.mount_directory, "/guest") .volume(tempdir.path(), "/output"); diff --git a/crates/util/compile/src/rust.rs b/crates/util/compile/src/rust.rs index 865957fb..b5664f76 100644 --- a/crates/util/compile/src/rust.rs +++ b/crates/util/compile/src/rust.rs @@ -157,8 +157,10 @@ impl CargoBuildCmd { } }; + let extra_rustflags = std::env::var("ERE_RUSTFLAGS").unwrap_or_default(); let encoded_rustflags = iter::empty() .chain(self.rustflags.iter().cloned()) + .chain(extra_rustflags.split_whitespace().map(String::from)) .chain( self.linker_script .as_ref() From 5aa6a0c3414031439c7e0d41101a100b5e6604c8 Mon Sep 17 00:00:00 2001 From: benbencik Date: Fri, 5 Jun 2026 17:19:42 +0200 Subject: [PATCH 4/4] add profile ere flags --- .../zisk/src/rust_rv64ima_customized.rs | 17 +++++++++++++---- crates/dockerized/src/compiler.rs | 1 + 2 files changed, 14 insertions(+), 4 deletions(-) diff --git a/crates/compiler/zisk/src/rust_rv64ima_customized.rs b/crates/compiler/zisk/src/rust_rv64ima_customized.rs index fad0f856..eed86690 100644 --- a/crates/compiler/zisk/src/rust_rv64ima_customized.rs +++ b/crates/compiler/zisk/src/rust_rv64ima_customized.rs @@ -8,9 +8,10 @@ use crate::Error; const ZISK_TOOLCHAIN: &str = "zisk"; const ZISK_TARGET: &str = "riscv64ima-zisk-zkvm-elf"; -const RUSTFLAGS: &[&str] = &[ - "-C", - "passes=lower-atomic", +const RUSTFLAGS: &[&str] = &["-C", "passes=lower-atomic"]; + +/// LLVM flags tuned by Optuna for the Ethrex guest on Zisk +const PROFILE_ETHREX: &[&str] = &[ "-C", "llvm-args=--inline-threshold=4749", "-C", @@ -59,6 +60,13 @@ const RUSTFLAGS: &[&str] = &[ "llvm-args=--disable-licm-promotion", ]; +fn profile_flags() -> &'static [&'static str] { + match std::env::var("ERE_PROFILE").as_deref() { + Ok("ethrex") => PROFILE_ETHREX, + _ => &[], + } +} + /// Compiler for Rust guest program to RV64IMA architecture, using customized /// Rust toolchain of ZisK. pub struct ZiskRustRv64imaCustomized; @@ -71,9 +79,10 @@ impl Compiler for ZiskRustRv64imaCustomized { guest_directory: impl AsRef, args: &[String], ) -> Result { + let flags: Vec<&str> = [profile_flags(), RUSTFLAGS].concat(); let elf = CargoBuildCmd::new() .toolchain(ZISK_TOOLCHAIN) - .rustflags(RUSTFLAGS) + .rustflags(&flags) .features(&parse_cargo_features(args)?) .exec(guest_directory, ZISK_TARGET)?; Ok(Elf(elf)) diff --git a/crates/dockerized/src/compiler.rs b/crates/dockerized/src/compiler.rs index 46f2d318..ab028498 100644 --- a/crates/dockerized/src/compiler.rs +++ b/crates/dockerized/src/compiler.rs @@ -147,6 +147,7 @@ impl Compiler for DockerizedCompiler { .inherit_env("NO_COLOR") .inherit_env("ERE_RUST_TOOLCHAIN") .inherit_env("ERE_RUSTFLAGS") + .inherit_env("ERE_PROFILE") .volume(&self.mount_directory, "/guest") .volume(tempdir.path(), "/output");