From d1eb7144db865eee50e0eab9c4d840d6581bf73a Mon Sep 17 00:00:00 2001 From: Ayush Shukla Date: Fri, 21 Nov 2025 20:01:49 +0100 Subject: [PATCH 1/3] chore: add tracing spans for aot exec methods --- Cargo.lock | 39 +++++++++++++++++------ crates/vm/src/arch/aot/metered_execute.rs | 17 +++++++++- crates/vm/src/arch/aot/pure.rs | 17 +++++++++- 3 files changed, 61 insertions(+), 12 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index 9f78579a1d..8242a1c18d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -1665,6 +1665,22 @@ dependencies = [ "zeroize", ] +[[package]] +name = "blstrs" +version = "0.7.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a8a8ed6fefbeef4a8c7b460e4110e12c5e22a5b7cf32621aae6ad650c4dcf29" +dependencies = [ + "blst", + "byte-slice-cast", + "ff 0.13.1", + "group 0.13.0", + "pairing 0.23.0", + "rand_core 0.6.4", + "serde", + "subtle", +] + [[package]] name = "bn-rs" version = "0.2.4" @@ -3609,7 +3625,9 @@ source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "f0f9ef7462f7c099f518d754361858f86d8a07af53ba9af0fe635bbccb151a63" dependencies = [ "ff 0.13.1", + "rand 0.8.5", "rand_core 0.6.4", + "rand_xorshift 0.3.0", "subtle", ] @@ -3807,9 +3825,10 @@ dependencies = [ [[package]] name = "halo2curves-axiom" version = "0.7.2" -source = "git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2#3a65a710e27fe03711f6fb4fc0c4469ae351974a" +source = "git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232#175e7c0cd818c436570f62c30fb01295ea287232" dependencies = [ "blake2b_simd", + "blstrs", "digest 0.10.7", "ff 0.13.1", "group 0.13.0", @@ -5255,7 +5274,7 @@ dependencies = [ "derive-new 0.6.0", "derive_more 1.0.0", "eyre", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "num-bigint 0.4.6", "num-traits", "openvm-algebra-transpiler", @@ -5293,7 +5312,7 @@ dependencies = [ name = "openvm-algebra-guest" version = "1.4.1" dependencies = [ - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "num-bigint 0.4.6", "once_cell", "openvm-algebra-complex-macros", @@ -5660,7 +5679,7 @@ dependencies = [ "cfg-if", "derive-new 0.6.0", "derive_more 1.0.0", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "hex-literal 0.4.1", "lazy_static", "num-bigint 0.4.6", @@ -5692,7 +5711,7 @@ dependencies = [ "ecdsa 0.16.9", "elliptic-curve 0.13.8", "group 0.13.0", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "once_cell", "openvm", "openvm-algebra-guest", @@ -5708,7 +5727,7 @@ name = "openvm-ecc-integration-tests" version = "1.4.1" dependencies = [ "eyre", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "hex-literal 0.4.1", "num-bigint 0.4.6", "openvm-algebra-transpiler", @@ -5879,7 +5898,7 @@ name = "openvm-mod-circuit-builder" version = "1.4.1" dependencies = [ "cuda-runtime-sys", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "itertools 0.14.0", "num-bigint 0.4.6", "num-traits", @@ -6007,7 +6026,7 @@ version = "1.4.1" dependencies = [ "eyre", "group 0.13.0", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "hex-literal 0.4.1", "itertools 0.14.0", "num-bigint 0.4.6", @@ -6047,7 +6066,7 @@ dependencies = [ "derive-new 0.6.0", "derive_more 1.0.0", "eyre", - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "num-bigint 0.4.6", "num-traits", "openvm-algebra-circuit", @@ -6073,7 +6092,7 @@ dependencies = [ name = "openvm-pairing-guest" version = "1.4.1" dependencies = [ - "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?tag=v0.7.2)", + "halo2curves-axiom 0.7.2 (git+https://github.com/axiom-crypto/halo2curves.git?rev=175e7c0cd818c436570f62c30fb01295ea287232)", "hex-literal 0.4.1", "itertools 0.14.0", "lazy_static", diff --git a/crates/vm/src/arch/aot/metered_execute.rs b/crates/vm/src/arch/aot/metered_execute.rs index 8daa4ea40e..43a7002053 100644 --- a/crates/vm/src/arch/aot/metered_execute.rs +++ b/crates/vm/src/arch/aot/metered_execute.rs @@ -362,7 +362,12 @@ where let mut vm_exec_state: Box> = Box::new(vm_exec_state); - unsafe { + #[cfg(feature = "metrics")] + let start = std::time::Instant::now(); + #[cfg(feature = "metrics")] + let start_instret = vm_exec_state.ctx.segmentation_ctx.instret; + + tracing::info_span!("execute_metered").in_scope(|| unsafe { let asm_run: libloading::Symbol = self .lib .get(b"asm_run") @@ -379,6 +384,16 @@ where from_state_pc, instret_until_end, ); + }); + + #[cfg(feature = "metrics")] + { + let elapsed = start.elapsed(); + let insns = vm_exec_state.ctx.segmentation_ctx.instret - start_instret; + tracing::info!("instructions_executed={insns}"); + metrics::counter!("execute_metered_insns").absolute(insns); + metrics::gauge!("execute_metered_insn_mi/s") + .set(insns as f64 / elapsed.as_micros() as f64); } Ok(*vm_exec_state) } diff --git a/crates/vm/src/arch/aot/pure.rs b/crates/vm/src/arch/aot/pure.rs index cea704489c..ec7dc48a09 100644 --- a/crates/vm/src/arch/aot/pure.rs +++ b/crates/vm/src/arch/aot/pure.rs @@ -288,9 +288,15 @@ where let ctx = ExecutionCtx::new(num_insns); let instret_left = ctx.instret_left; + #[cfg(feature = "metrics")] + let start = std::time::Instant::now(); + #[cfg(feature = "metrics")] + let start_instret_left = instret_left; + let mut vm_exec_state: Box> = Box::new(VmExecState::new(from_state, ctx)); - unsafe { + + tracing::info_span!("execute_e1").in_scope(|| unsafe { let asm_run: libloading::Symbol = self .lib .get(b"asm_run") @@ -306,6 +312,15 @@ where from_state_pc, instret_left, ); + }); + + #[cfg(feature = "metrics")] + { + let elapsed = start.elapsed(); + let insns = start_instret_left - vm_exec_state.ctx.instret_left; + tracing::info!("instructions_executed={insns}"); + metrics::counter!("execute_e1_insns").absolute(insns); + metrics::gauge!("execute_e1_insn_mi/s").set(insns as f64 / elapsed.as_micros() as f64); } if num_insns.is_some() { From 9760bec28475f80b67ec06cd455f3653828a3283 Mon Sep 17 00:00:00 2001 From: Ayush Shukla Date: Fri, 21 Nov 2025 20:34:52 +0100 Subject: [PATCH 2/3] chore: add _aot suffix for span --- crates/vm/src/arch/aot/metered_execute.rs | 2 +- crates/vm/src/arch/aot/pure.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/vm/src/arch/aot/metered_execute.rs b/crates/vm/src/arch/aot/metered_execute.rs index 43a7002053..81fda74448 100644 --- a/crates/vm/src/arch/aot/metered_execute.rs +++ b/crates/vm/src/arch/aot/metered_execute.rs @@ -367,7 +367,7 @@ where #[cfg(feature = "metrics")] let start_instret = vm_exec_state.ctx.segmentation_ctx.instret; - tracing::info_span!("execute_metered").in_scope(|| unsafe { + tracing::info_span!("execute_metered_aot").in_scope(|| unsafe { let asm_run: libloading::Symbol = self .lib .get(b"asm_run") diff --git a/crates/vm/src/arch/aot/pure.rs b/crates/vm/src/arch/aot/pure.rs index ec7dc48a09..2bdba9662b 100644 --- a/crates/vm/src/arch/aot/pure.rs +++ b/crates/vm/src/arch/aot/pure.rs @@ -296,7 +296,7 @@ where let mut vm_exec_state: Box> = Box::new(VmExecState::new(from_state, ctx)); - tracing::info_span!("execute_e1").in_scope(|| unsafe { + tracing::info_span!("execute_pure_aot").in_scope(|| unsafe { let asm_run: libloading::Symbol = self .lib .get(b"asm_run") From b87d0ec2ec981a534921f6ac7fb38cf61f5aa414 Mon Sep 17 00:00:00 2001 From: Ayush Shukla Date: Fri, 21 Nov 2025 21:50:47 +0100 Subject: [PATCH 3/3] Revert "chore: add _aot suffix for span" This reverts commit 9760bec28475f80b67ec06cd455f3653828a3283. --- crates/vm/src/arch/aot/metered_execute.rs | 2 +- crates/vm/src/arch/aot/pure.rs | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/crates/vm/src/arch/aot/metered_execute.rs b/crates/vm/src/arch/aot/metered_execute.rs index 81fda74448..43a7002053 100644 --- a/crates/vm/src/arch/aot/metered_execute.rs +++ b/crates/vm/src/arch/aot/metered_execute.rs @@ -367,7 +367,7 @@ where #[cfg(feature = "metrics")] let start_instret = vm_exec_state.ctx.segmentation_ctx.instret; - tracing::info_span!("execute_metered_aot").in_scope(|| unsafe { + tracing::info_span!("execute_metered").in_scope(|| unsafe { let asm_run: libloading::Symbol = self .lib .get(b"asm_run") diff --git a/crates/vm/src/arch/aot/pure.rs b/crates/vm/src/arch/aot/pure.rs index 2bdba9662b..ec7dc48a09 100644 --- a/crates/vm/src/arch/aot/pure.rs +++ b/crates/vm/src/arch/aot/pure.rs @@ -296,7 +296,7 @@ where let mut vm_exec_state: Box> = Box::new(VmExecState::new(from_state, ctx)); - tracing::info_span!("execute_pure_aot").in_scope(|| unsafe { + tracing::info_span!("execute_e1").in_scope(|| unsafe { let asm_run: libloading::Symbol = self .lib .get(b"asm_run")