From 71edd3584b5ed8045f27e2dea1a4fbc26bb56bef Mon Sep 17 00:00:00 2001 From: Xinding Wei Date: Tue, 26 Nov 2024 13:52:35 -0800 Subject: [PATCH] Strip debug_info when not collecting metrics (#865) --- toolchain/instructions/src/program.rs | 11 +++++++++++ vm/src/arch/segment.rs | 5 +++++ 2 files changed, 16 insertions(+) diff --git a/toolchain/instructions/src/program.rs b/toolchain/instructions/src/program.rs index 8a85b937ac..64c5e6fedf 100644 --- a/toolchain/instructions/src/program.rs +++ b/toolchain/instructions/src/program.rs @@ -77,6 +77,17 @@ impl Program { } } + pub fn strip_debug_infos(self) -> Self { + Self { + instructions_and_debug_infos: self + .instructions_and_debug_infos + .into_iter() + .map(|opt| opt.map(|(ins, _)| (ins, None))) + .collect(), + ..self + } + } + pub fn from_instructions(instructions: &[Instruction]) -> Self { Self::new_without_debug_infos( instructions, diff --git a/vm/src/arch/segment.rs b/vm/src/arch/segment.rs index 6ff91aff20..6ed7becddf 100644 --- a/vm/src/arch/segment.rs +++ b/vm/src/arch/segment.rs @@ -90,6 +90,11 @@ impl ExecutionSegment { ) -> Self { let mut chip_set = config.create_chip_set(); chip_set.set_streams(streams); + let program = if config.collect_metrics { + program + } else { + program.strip_debug_infos() + }; chip_set.set_program(program); if let Some(initial_memory) = initial_memory {