Commit 56504a0
authored
Rollup merge of #80042 - sivadeilra:cold_bits, r=oli-obk
Split a func into cold/hot parts, reducing binary size
I noticed that the Size::bits function is called in many places,
and is inlined into them. On x86_64-pc-windows-msvc, this function
is inlined 527 times, and compiled separately (non-inlined) 3 times.
Each of those inlined calls contains code that panics. This commit
moves the `panic!` call into a separate function and marks that
function with `#[cold]`.
This reduces binary size by 24 KB. Not much, but it's something.
Changes like this often reduce pressure on instruction-caches,
since it reduces the amount of code that is inlined into hot code
paths. Or more precisely, it removes cold code from hot cache lines.1 file changed
+20
-6
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
271 | 271 | | |
272 | 272 | | |
273 | 273 | | |
| 274 | + | |
274 | 275 | | |
275 | 276 | | |
276 | 277 | | |
277 | 278 | | |
278 | 279 | | |
279 | 280 | | |
280 | | - | |
| 281 | + | |
| 282 | + | |
281 | 283 | | |
282 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
| 290 | + | |
| 291 | + | |
| 292 | + | |
| 293 | + | |
| 294 | + | |
| 295 | + | |
| 296 | + | |
| 297 | + | |
283 | 298 | | |
284 | | - | |
| 299 | + | |
285 | 300 | | |
286 | 301 | | |
287 | 302 | | |
288 | 303 | | |
289 | | - | |
| 304 | + | |
| 305 | + | |
290 | 306 | | |
291 | 307 | | |
292 | 308 | | |
| |||
301 | 317 | | |
302 | 318 | | |
303 | 319 | | |
304 | | - | |
305 | | - | |
306 | | - | |
| 320 | + | |
307 | 321 | | |
308 | 322 | | |
309 | 323 | | |
| |||
0 commit comments