Skip to content

Commit

Permalink
feat(sdk): enhance dev mode warning with opt-level detection
Browse files Browse the repository at this point in the history
- Add opt-level detection in build script
- Set environment variable when optimization level is low
- Update warning message to be more visible with clear instructions
- Replace debug_assertions check with opt-level detection

Co-Authored-By: [email protected] <[email protected]>
  • Loading branch information
devin-ai-integration[bot] and ctian1 committed Dec 12, 2024
1 parent aa5d953 commit fec1195
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 2 deletions.
5 changes: 5 additions & 0 deletions crates/sdk/build.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
fn main() {
vergen::EmitBuilder::builder().build_timestamp().git_sha(true).emit().unwrap();

let opt_level = std::env::var("OPT_LEVEL").unwrap_or_else(|_| "0".to_string());
if opt_level == "0" || opt_level == "1" {
println!("cargo:rustc-env=SP1_OPT_LEVEL_IS_LOW=1");
}
}
11 changes: 9 additions & 2 deletions crates/sdk/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,15 @@ impl ProverClient {
match env::var("SP1_PROVER").unwrap_or("local".to_string()).to_lowercase().as_str() {
"mock" => Self { prover: Box::new(MockProver::new()) },
"local" => {
#[cfg(debug_assertions)]
eprintln!("Warning: Local prover in dev mode is not recommended. Proof generation may be slow.");
if option_env!("SP1_OPT_LEVEL_IS_LOW").is_some() {
eprintln!("\n⚠️ WARNING: Local prover is running with low optimization level (dev mode) ⚠️");
eprintln!("This will significantly impact proof generation performance.");
eprintln!("To improve performance, either:");
eprintln!(" 1. Use --release flag when running cargo");
eprintln!(" 2. Add the following to Cargo.toml:");
eprintln!(" [profile.dev.package.\"*\"]");
eprintln!(" opt-level = 3\n");
}
Self {
#[cfg(not(feature = "cuda"))]
prover: Box::new(CpuProver::new()),
Expand Down

0 comments on commit fec1195

Please sign in to comment.