File tree Expand file tree Collapse file tree 2 files changed +25
-2
lines changed
src/executor/wall_time/perf Expand file tree Collapse file tree 2 files changed +25
-2
lines changed Original file line number Diff line number Diff line change @@ -47,7 +47,7 @@ fn main() {
4747 . set_integration ( "codspeed-rust" , env ! ( "CARGO_PKG_VERSION" ) )
4848 . unwrap ( ) ;
4949
50- const NUM_ITERATIONS : usize = 1 ;
50+ const NUM_ITERATIONS : usize = 5 ;
5151 let mut times_per_round_ns = Vec :: with_capacity ( NUM_ITERATIONS ) ;
5252
5353 hooks. start_benchmark ( ) . unwrap ( ) ;
Original file line number Diff line number Diff line change @@ -106,7 +106,30 @@ impl ModuleSymbols {
106106 } ) ) ;
107107 }
108108
109- symbols. retain ( |symbol| symbol. addr > 0 && symbol. size > 0 ) ;
109+ // Update zero-sized symbols to cover the range until the next symbol
110+ // This is what perf does
111+ // https://github.com/torvalds/linux/blob/e538109ac71d801d26776af5f3c54f548296c29c/tools/perf/util/symbol.c#L256
112+ // A common source for these is inline assembly functions.
113+ symbols. sort_by_key ( |symbol| symbol. addr ) ;
114+ for i in 0 ..symbols. len ( ) {
115+ if symbols[ i] . size == 0 {
116+ if i + 1 < symbols. len ( ) {
117+ // Set size to the distance to the next symbol
118+ symbols[ i] . size = symbols[ i + 1 ] . addr . saturating_sub ( symbols[ i] . addr ) ;
119+ } else {
120+ // Last symbol: round up to next 4KB page boundary and add 4KiB
121+ // This matches perf's behavior: roundup(curr->start, 4096) + 4096
122+ const PAGE_SIZE : u64 = 4096 ;
123+ let addr = symbols[ i] . addr ;
124+ let end_addr = addr. next_multiple_of ( PAGE_SIZE ) + PAGE_SIZE ;
125+ symbols[ i] . size = end_addr. saturating_sub ( addr) ;
126+ }
127+ }
128+ }
129+
130+ // Filter out any symbols that still have zero size
131+ symbols. retain ( |symbol| symbol. size > 0 ) ;
132+
110133 if symbols. is_empty ( ) {
111134 return Err ( anyhow:: anyhow!( "No symbols found" ) ) ;
112135 }
You can’t perform that action at this time.
0 commit comments