Skip to content

Commit 1b98e09

Browse files
committed
fix: ignore statically linked python
1 parent 720ad25 commit 1b98e09

2 files changed

Lines changed: 28 additions & 0 deletions

File tree

src/run/runner/wall_time/perf/mod.rs

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -441,6 +441,30 @@ impl BenchmarkData {
441441
}
442442
}
443443

444+
// When python is statically linked, we'll not find it in the ignored modules. Add it manually:
445+
let python_modules = self.symbols_by_pid.values().filter_map(|proc| {
446+
proc.loaded_modules().find(|path| {
447+
path.file_name()
448+
.map(|name| name.to_string_lossy().starts_with("python"))
449+
.unwrap_or(false)
450+
})
451+
});
452+
for path in python_modules {
453+
if let Some(mapping) = self
454+
.symbols_by_pid
455+
.values()
456+
.find_map(|proc| proc.module_mapping(path))
457+
{
458+
let (Some((base_addr, _)), Some((_, end_addr))) = (
459+
mapping.iter().min_by_key(|(base_addr, _)| base_addr),
460+
mapping.iter().max_by_key(|(_, end_addr)| end_addr),
461+
) else {
462+
continue;
463+
};
464+
to_ignore.push((path.to_string_lossy().into(), *base_addr, *end_addr));
465+
}
466+
}
467+
444468
to_ignore
445469
},
446470
};

src/run/runner/wall_time/perf/perf_map.rs

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -213,6 +213,10 @@ impl ProcessSymbols {
213213
.push((start_addr, end_addr));
214214
}
215215

216+
pub fn loaded_modules(&self) -> impl Iterator<Item = &PathBuf> {
217+
self.modules.keys()
218+
}
219+
216220
pub fn module_mapping<P: AsRef<std::path::Path>>(
217221
&self,
218222
module_path: P,

0 commit comments

Comments
 (0)