MCPcopy Create free account
hub / github.com/CodSpeedHQ/codspeed / read_mappings

Function read_mappings

src/executor/memory/module_artifacts.rs:83–104  ·  view source on GitHub ↗
(results_folder: &Path)

Source from the content-addressed store, hash-verified

81}
82
83fn read_mappings(results_folder: &Path) -> Result<Vec<ProcessMapping>> {
84 let suffix = format!(".{}.msgpack", MemtrackArtifact::name());
85
86 let mut mappings = Vec::new();
87 for entry in std::fs::read_dir(results_folder)?.filter_map(Result::ok) {
88 if !entry.file_name().to_string_lossy().ends_with(&suffix) {
89 continue;
90 }
91
92 let file = std::fs::File::open(entry.path())?;
93 // SAFETY: read-only mapping of an artifact memtrack finished writing
94 // before it exited; nothing writes to it while the runner reads it.
95 let artifact = unsafe { memmap2::Mmap::map(&file)? };
96 mappings.extend(
97 read_mappings_from_artifact(&artifact)
98 .with_context(|| format!("Failed to decode {:?}", entry.path()))?,
99 );
100 }
101
102 mappings.sort_unstable_by_key(|mapping| (mapping.pid, mapping.timestamp));
103 Ok(mappings)
104}
105
106/// Reconstruct mappings across forks because inherited perf events do not
107/// synthesize mappings that already existed when a child was forked.

Calls 3

pathMethod · 0.80
file_nameMethod · 0.45