Skip to content

Commit dc2dc85

Browse files
authored
Merge pull request #128 from vvuk/vladv/fix-mac-sample
Tag samples with time as close as possible to the time they were taken
2 parents 2f94ef1 + df24932 commit dc2dc85

File tree

1 file changed

+7
-1
lines changed

1 file changed

+7
-1
lines changed

samply/src/mac/thread_profiler.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@ use framehop::FrameAddress;
22
use fxprof_processed_profile::{CpuDelta, Profile, ThreadHandle, Timestamp};
33
use mach::mach_types::thread_act_t;
44
use mach::port::mach_port_t;
5+
use time::get_monotonic_timestamp;
56

67
use std::mem;
78

9+
use crate::mac::time;
810
use crate::shared::recycling::ThreadRecycler;
911
use crate::shared::types::{StackFrame, StackMode};
1012
use crate::shared::unresolved_samples::{UnresolvedSamples, UnresolvedStacks};
@@ -140,6 +142,10 @@ impl ThreadProfiler {
140142
stack_scratch_buffer,
141143
fold_recursive_prefix,
142144
)?;
145+
// make sure to use the time immediately after the stack is sampled so that any
146+
// jitdump records emitted in the interval between samply starting to sample
147+
// all tasks and actually stopping the thread are properly used
148+
let sample_time_mono = get_monotonic_timestamp();
143149

144150
let frames = stack_scratch_buffer.iter().rev().map(|f| match f {
145151
FrameAddress::InstructionPointer(address) => {
@@ -153,7 +159,7 @@ impl ThreadProfiler {
153159
unresolved_samples.add_sample(
154160
self.profile_thread,
155161
now,
156-
now_mono,
162+
sample_time_mono,
157163
stack,
158164
cpu_delta,
159165
1,

0 commit comments

Comments
 (0)