Commit 2ed8e5b
committed
perf(callgrind): cut redundant debug-info address lookups on the dump path
Writing the profile at exit queries file/line information for every
instruction address of every dumped basic block (~141k addresses for
`python3 testdata/test.py`). Almost all of that work is redundant:
consecutive addresses belong to the same source line and the same
source file.
- Add a one-entry range cache to search_all_loctabs(). It answers a
query that lands in the last hit loctab entry (or the next one) with
a couple of compares instead of walking every DebugInfo and binary
searching its loctab. It is only reused within the epoch it was found
in and is dropped by advance_current_DiEpoch(), so a stale DebugInfo
can never be read.
- Return early from VG_(get_inline_fnname) when --read-inline-info=no.
No inltab is built in that case, so the answer is always "no inlined
function", but the loctab search was still performed for every dumped
address. This mirrors the guard already present in VG_(new_IIPC).
- Memoize the last file_node in get_debug_pos(). The existing debug
cache is keyed by instruction address so it never hits while walking
the distinct addresses of a basic block; every miss called
CLG_(get_file_node), which rebuilds and rehashes the absolute source
path. The memo compares the interned (dir, file) pointers and is
reset by init_debug_cache() at the start of each dump.
Callgrind output is byte-for-byte identical to the previous build.1 parent ae6bf15 commit 2ed8e5b
2 files changed
Lines changed: 97 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
361 | 361 | | |
362 | 362 | | |
363 | 363 | | |
| 364 | + | |
| 365 | + | |
| 366 | + | |
| 367 | + | |
| 368 | + | |
| 369 | + | |
| 370 | + | |
| 371 | + | |
| 372 | + | |
| 373 | + | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
| 378 | + | |
| 379 | + | |
| 380 | + | |
| 381 | + | |
| 382 | + | |
364 | 383 | | |
365 | 384 | | |
366 | 385 | | |
| |||
372 | 391 | | |
373 | 392 | | |
374 | 393 | | |
| 394 | + | |
| 395 | + | |
| 396 | + | |
| 397 | + | |
375 | 398 | | |
376 | 399 | | |
377 | 400 | | |
| |||
397 | 420 | | |
398 | 421 | | |
399 | 422 | | |
400 | | - | |
| 423 | + | |
| 424 | + | |
| 425 | + | |
| 426 | + | |
| 427 | + | |
| 428 | + | |
| 429 | + | |
| 430 | + | |
| 431 | + | |
| 432 | + | |
| 433 | + | |
| 434 | + | |
| 435 | + | |
| 436 | + | |
| 437 | + | |
401 | 438 | | |
402 | 439 | | |
403 | 440 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
137 | 137 | | |
138 | 138 | | |
139 | 139 | | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
140 | 143 | | |
141 | 144 | | |
| 145 | + | |
| 146 | + | |
142 | 147 | | |
143 | 148 | | |
144 | 149 | | |
| |||
2138 | 2143 | | |
2139 | 2144 | | |
2140 | 2145 | | |
| 2146 | + | |
| 2147 | + | |
| 2148 | + | |
| 2149 | + | |
| 2150 | + | |
| 2151 | + | |
| 2152 | + | |
| 2153 | + | |
| 2154 | + | |
| 2155 | + | |
| 2156 | + | |
| 2157 | + | |
| 2158 | + | |
| 2159 | + | |
| 2160 | + | |
| 2161 | + | |
| 2162 | + | |
| 2163 | + | |
| 2164 | + | |
| 2165 | + | |
| 2166 | + | |
| 2167 | + | |
| 2168 | + | |
| 2169 | + | |
| 2170 | + | |
| 2171 | + | |
| 2172 | + | |
| 2173 | + | |
| 2174 | + | |
2141 | 2175 | | |
2142 | 2176 | | |
2143 | 2177 | | |
| |||
2146 | 2180 | | |
2147 | 2181 | | |
2148 | 2182 | | |
| 2183 | + | |
| 2184 | + | |
| 2185 | + | |
| 2186 | + | |
| 2187 | + | |
| 2188 | + | |
| 2189 | + | |
| 2190 | + | |
| 2191 | + | |
| 2192 | + | |
| 2193 | + | |
| 2194 | + | |
| 2195 | + | |
| 2196 | + | |
| 2197 | + | |
| 2198 | + | |
| 2199 | + | |
| 2200 | + | |
| 2201 | + | |
2149 | 2202 | | |
2150 | 2203 | | |
2151 | 2204 | | |
| |||
2155 | 2208 | | |
2156 | 2209 | | |
2157 | 2210 | | |
| 2211 | + | |
| 2212 | + | |
| 2213 | + | |
2158 | 2214 | | |
2159 | 2215 | | |
2160 | 2216 | | |
| |||
2384 | 2440 | | |
2385 | 2441 | | |
2386 | 2442 | | |
| 2443 | + | |
| 2444 | + | |
| 2445 | + | |
2387 | 2446 | | |
2388 | 2447 | | |
2389 | 2448 | | |
| |||
0 commit comments