From 02754ce14f2853e9c452b98be6573ae05d26996b Mon Sep 17 00:00:00 2001 From: Leandro Pacheco Date: Tue, 21 Oct 2025 16:59:13 -0300 Subject: [PATCH 1/2] air_id to differentiate airs with the same name in metrics (#10) (#16) --- crates/stark-backend/src/prover/metrics.rs | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/crates/stark-backend/src/prover/metrics.rs b/crates/stark-backend/src/prover/metrics.rs index ef00d15f..07f5f464 100644 --- a/crates/stark-backend/src/prover/metrics.rs +++ b/crates/stark-backend/src/prover/metrics.rs @@ -19,6 +19,8 @@ pub struct TraceMetrics { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SingleTraceMetrics { pub air_name: String, + /// air_name comes from the Air rust type, this allows us to differentiate multiple chips using the same type + pub air_id: usize, pub height: usize, /// The after challenge width is adjusted to be in terms of **base field** elements. pub width: TraceWidth, @@ -94,7 +96,8 @@ pub fn trace_metrics( }) .collect::>(); let per_air: Vec<_> = zip_eq(&mpk.per_air, heights) - .map(|(pk, height)| { + .enumerate() + .map(|(idx, (pk, height))| { let air_name = &pk.air_name; let mut width = pk.vk.params.width.clone(); let ext_degree = PB::CHALLENGE_EXT_DEGREE as usize; @@ -115,6 +118,7 @@ pub fn trace_metrics( .sum::(); SingleTraceMetrics { air_name: air_name.to_string(), + air_id: mpk.air_ids[idx], height, width, cells, @@ -216,7 +220,10 @@ mod emit { impl SingleTraceMetrics { pub fn emit(&self) { - let labels = [("air_name", self.air_name.clone())]; + let labels = [ + ("air_name", self.air_name.clone()), + ("air_id", self.air_id.to_string()), + ]; counter!("rows", &labels).absolute(self.height as u64); counter!("cells", &labels).absolute(self.total_cells as u64); counter!("prep_cols", &labels).absolute(self.width.preprocessed.unwrap_or(0) as u64); From 986dd68b1138ad91544dcd77197178115f4453b7 Mon Sep 17 00:00:00 2001 From: schaeff Date: Fri, 31 Oct 2025 16:11:30 +0100 Subject: [PATCH 2/2] clean --- crates/stark-backend/src/prover/metrics.rs | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/crates/stark-backend/src/prover/metrics.rs b/crates/stark-backend/src/prover/metrics.rs index 07f5f464..f8688008 100644 --- a/crates/stark-backend/src/prover/metrics.rs +++ b/crates/stark-backend/src/prover/metrics.rs @@ -19,7 +19,6 @@ pub struct TraceMetrics { #[derive(Clone, Debug, Serialize, Deserialize)] pub struct SingleTraceMetrics { pub air_name: String, - /// air_name comes from the Air rust type, this allows us to differentiate multiple chips using the same type pub air_id: usize, pub height: usize, /// The after challenge width is adjusted to be in terms of **base field** elements. @@ -95,9 +94,8 @@ pub fn trace_metrics( (weighted_sum, trace_height_constraint.threshold as usize) }) .collect::>(); - let per_air: Vec<_> = zip_eq(&mpk.per_air, heights) - .enumerate() - .map(|(idx, (pk, height))| { + let per_air: Vec<_> = zip_eq(mpk.air_ids.iter().copied(), zip_eq(&mpk.per_air, heights)) + .map(|(air_id, (pk, height))| { let air_name = &pk.air_name; let mut width = pk.vk.params.width.clone(); let ext_degree = PB::CHALLENGE_EXT_DEGREE as usize; @@ -118,7 +116,7 @@ pub fn trace_metrics( .sum::(); SingleTraceMetrics { air_name: air_name.to_string(), - air_id: mpk.air_ids[idx], + air_id, height, width, cells,