Skip to content

Commit

Permalink
Make work
Browse files Browse the repository at this point in the history
  • Loading branch information
vvuk committed Apr 23, 2024
1 parent efbebef commit 4c0ba4f
Show file tree
Hide file tree
Showing 4 changed files with 149 additions and 107 deletions.
12 changes: 9 additions & 3 deletions samply/src/linux_shared/process.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
use std::path::{Path, PathBuf};

use framehop::Unwinder;
use rangemap::RangeSet;
use fxprof_processed_profile::{
CategoryHandle, CounterHandle, LibraryHandle, MarkerTiming, ProcessHandle, Profile,
ThreadHandle, Timestamp,
Expand Down Expand Up @@ -167,7 +168,7 @@ where
profile: &mut Profile,
jit_category_manager: &mut JitCategoryManager,
timestamp_converter: &TimestampConverter,
) -> (ProcessSampleData, Option<(String, ProcessRecyclingData)>) {
) -> (ProcessSampleData, Option<(String, ProcessRecyclingData)>, Option<RangeSet<Timestamp>>) {
self.unwinder = U::default();

let perf_map_mappings = if !self.unresolved_samples.is_empty() {
Expand All @@ -189,13 +190,18 @@ where
timestamp_converter,
);

let mut marker_ranges: Option<RangeSet<Timestamp>> = None;
let mut marker_spans = Vec::new();
for (thread_handle, marker_file_path, fallback_dir) in self.marker_file_paths {
if let Ok(marker_spans_from_this_file) = get_markers(
if let Ok((marker_spans_from_this_file, maybe_ranges)) = get_markers(
&marker_file_path,
None,
fallback_dir.as_deref(),
*timestamp_converter,
) {
if let Some(ranges) = maybe_ranges {
marker_ranges.get_or_insert_with(|| RangeSet::new()).extend(ranges);
}
marker_spans.extend(marker_spans_from_this_file.into_iter().map(|span| {
MarkerSpanOnThread {
thread_handle,
Expand Down Expand Up @@ -235,7 +241,7 @@ where
None
};

(process_sample_data, process_recycling_data)
(process_sample_data, process_recycling_data, marker_ranges)
}

#[allow(clippy::too_many_arguments)]
Expand Down
11 changes: 9 additions & 2 deletions samply/src/linux_shared/processes.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use fxprof_processed_profile::{CategoryColor, Profile, Timestamp};

use std::collections::hash_map::Entry;
use std::collections::HashMap;
use rangemap::RangeSet;

use super::process::Process;

Expand Down Expand Up @@ -148,7 +149,7 @@ where

process.notify_dead(time, profile);

let (process_sample_data, process_recycling_data) =
let (process_sample_data, process_recycling_data, _process_range_data) =
process.finish(profile, jit_category_manager, timestamp_converter);
if !process_sample_data.is_empty() {
self.process_sample_datas.push(process_sample_data);
Expand Down Expand Up @@ -201,13 +202,18 @@ where
jit_category_manager: &mut JitCategoryManager,
timestamp_converter: &TimestampConverter,
) {
let mut full_marker_ranges = None;

// Gather the ProcessSampleData from any processes which are still alive at the end of profiling.
for process in self.processes_by_pid.into_values() {
let (process_sample_data, _process_recycling_data) =
let (process_sample_data, _process_recycling_data, process_range_data) =
process.finish(profile, jit_category_manager, timestamp_converter);
if !process_sample_data.is_empty() {
self.process_sample_datas.push(process_sample_data);
}
if let Some(process_range_data) = process_range_data {
full_marker_ranges.get_or_insert_with(|| RangeSet::new()).extend(process_range_data);
}
}

let user_category = profile.add_category("User", CategoryColor::Yellow).into();
Expand All @@ -221,6 +227,7 @@ where
&mut stack_frame_scratch_buf,
unresolved_stacks,
event_names,
full_marker_ranges.as_ref(),
);
}
}
Expand Down
Loading

0 comments on commit 4c0ba4f

Please sign in to comment.