File tree Expand file tree Collapse file tree
src/run/runner/wall_time/perf Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ pub fn find_pid<P: AsRef<std::path::Path>>(path: P) -> anyhow::Result<i32> {
1313 } = PerfFileReader :: parse_file ( reader) ?;
1414
1515 let mut pid_freq = HashMap :: new ( ) ;
16+
17+ // Only consider the first N events to reduce the performance impact. Certain benchmark libraries can generate
18+ // more than 100k for each benchmark, which can slow down the runner a lot. The highest chance of finding
19+ // different pids is in the first few events, where there's a possible overlap.
20+ const COUNT_FIRST_N : usize = 1000 ;
21+ let mut i = 0 ;
22+
1623 while let Some ( record) = record_iter. next_record ( & mut perf_file) ? {
1724 let PerfFileRecord :: EventRecord { record, .. } = record else {
1825 continue ;
@@ -33,6 +40,11 @@ pub fn find_pid<P: AsRef<std::path::Path>>(path: P) -> anyhow::Result<i32> {
3340
3441 if let Some ( pid) = event. pid {
3542 * pid_freq. entry ( pid) . or_insert ( 0 ) += 1 ;
43+
44+ i += 1 ;
45+ if i >= COUNT_FIRST_N {
46+ break ;
47+ }
3648 }
3749 }
3850
You can’t perform that action at this time.
0 commit comments