diff --git a/samply/src/mac/thread_profiler.rs b/samply/src/mac/thread_profiler.rs index 1ab285649..82e94a8eb 100644 --- a/samply/src/mac/thread_profiler.rs +++ b/samply/src/mac/thread_profiler.rs @@ -2,9 +2,11 @@ use framehop::FrameAddress; use fxprof_processed_profile::{CpuDelta, Profile, ThreadHandle, Timestamp}; use mach::mach_types::thread_act_t; use mach::port::mach_port_t; +use time::get_monotonic_timestamp; use std::mem; +use crate::mac::time; use crate::shared::recycling::ThreadRecycler; use crate::shared::types::{StackFrame, StackMode}; use crate::shared::unresolved_samples::{UnresolvedSamples, UnresolvedStacks}; @@ -140,6 +142,10 @@ impl ThreadProfiler { stack_scratch_buffer, fold_recursive_prefix, )?; + // make sure to use the time immediately after the stack is sampled so that any + // jitdump records emitted in the interval between samply starting to sample + // all tasks and actually stopping the thread are properly used + let sample_time_mono = get_monotonic_timestamp(); let frames = stack_scratch_buffer.iter().rev().map(|f| match f { FrameAddress::InstructionPointer(address) => { @@ -153,7 +159,7 @@ impl ThreadProfiler { unresolved_samples.add_sample( self.profile_thread, now, - now_mono, + sample_time_mono, stack, cpu_delta, 1,