Skip to content

Commit

Permalink
fix: use global clk
Browse files Browse the repository at this point in the history
  • Loading branch information
nhtyy committed Nov 14, 2024
1 parent 30472d9 commit 9c5d7fc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
4 changes: 2 additions & 2 deletions crates/core/executor/src/executor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -202,7 +202,7 @@ impl<'a> Executor<'a> {
.unwrap_or(1);

this.profiler = Some((
Profiler::new(elf_bytes, sample_rate).expect("Failed to create profiler"),
Profiler::new(elf_bytes, sample_rate as u64).expect("Failed to create profiler"),
trace_buf,
));
}
Expand Down Expand Up @@ -1662,7 +1662,7 @@ impl<'a> Executor<'a> {
fn log(&mut self, _: &Instruction) {
if let Some((ref mut profiler, _)) = self.profiler {
if !self.unconstrained {
profiler.record(self.state.clk, self.state.pc as u64);
profiler.record(self.state.global_clk, self.state.pc as u64);
}
}

Expand Down
6 changes: 3 additions & 3 deletions crates/core/executor/src/profiler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ pub enum ProfilerError {
/// During exeuction, the profiler always keeps track of the callstack
/// and will occasionally save the stack according to the sample rate.
pub struct Profiler {
sample_rate: u32,
sample_rate: u64,
/// `start_address`-> index in `function_ranges`
start_lookup: HashMap<u64, usize>,
/// the start and end of the function
Expand All @@ -44,7 +44,7 @@ struct Sample {
}

impl Profiler {
pub(super) fn new(elf_bytes: &[u8], sample_rate: u32) -> Result<Self, ProfilerError> {
pub(super) fn new(elf_bytes: &[u8], sample_rate: u64) -> Result<Self, ProfilerError> {
let elf = Elf::parse(elf_bytes)?;

let mut start_lookup = HashMap::new();
Expand Down Expand Up @@ -91,7 +91,7 @@ impl Profiler {
})
}

pub(super) fn record(&mut self, clk: u32, pc: u64) {
pub(super) fn record(&mut self, clk: u64, pc: u64) {
// We are still in the current function.
if pc > self.current_function_range.0 && pc <= self.current_function_range.1 {
if clk % self.sample_rate == 0 {
Expand Down

0 comments on commit 9c5d7fc

Please sign in to comment.