Skip to content

Commit

Permalink
Only recycle threads when --reuse-threads is specified.
Browse files Browse the repository at this point in the history
This fixes unintended behavior - we were always combining non-overlapping threads with
the same name inside the same process into one thread. We only want to do that if
--reuse-threads is specified.
  • Loading branch information
mstange committed Mar 7, 2024
1 parent d6f9edf commit 7c4ad6d
Showing 1 changed file with 21 additions and 5 deletions.
26 changes: 21 additions & 5 deletions samply/src/linux_shared/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -86,13 +86,21 @@ where
if let Some(name) = name.as_deref() {
profile.set_thread_name(main_thread_handle, name);
}
let (thread_recycler, jit_function_recycler) = if self.process_recycler.is_some() {
(
Some(ThreadRecycler::new()),
Some(JitFunctionRecycler::default()),
)
} else {
(None, None)
};
let process = Process::new(
pid,
process_handle,
main_thread_handle,
name,
Some(ThreadRecycler::new()),
Some(JitFunctionRecycler::default()),
thread_recycler,
jit_function_recycler,
);
entry.insert(process)
}
Expand All @@ -107,13 +115,21 @@ where
profile.add_process(&format!("<{pid}>"), pid as u32, fake_start_time);
let main_thread_handle =
profile.add_thread(process_handle, pid as u32, fake_start_time, true);
let (thread_recycler, jit_function_recycler) = if self.process_recycler.is_some() {
(
Some(ThreadRecycler::new()),
Some(JitFunctionRecycler::default()),
)
} else {
(None, None)
};
Process::new(
pid,
process_handle,
main_thread_handle,
None,
Some(ThreadRecycler::new()),
Some(JitFunctionRecycler::default()),
None, // no name
thread_recycler,
jit_function_recycler,
)
})
}
Expand Down

0 comments on commit 7c4ad6d

Please sign in to comment.