10 Aug 2024 |
Randy Eckenrode | * Wouldn’t that only matter for LTO, which crates have to opt into using? I know there’s a startup penalty for dynamic linking, but is there any other penalties? Darwin is PIE, so there’s no avoiding the overhead of that by using static archives. | 20:07:00 |
Randy Eckenrode | * Wouldn’t that only matter for LTO, which crates have to opt into using? I know there’s a startup penalty for dynamic linking, but are there any other penalties? Darwin is PIE, so there’s no avoiding the overhead of that by using static archives. | 20:07:20 |
Randy Eckenrode | * Wouldn’t that only matter for LTO, which crates have to opt into using? I know there’s a startup penalty for dynamic linking, but are there any other penalties? Darwin is PIE, so there’s no avoiding the overhead of position-independence/ASLR by using static archives. | 20:07:33 |
Randy Eckenrode | * Wouldn’t that only matter for LTO, which crates have to opt into using? I know there’s a startup penalty for dynamic linking, but are there any other penalties? Darwin is PIE, so there’s no avoiding the overhead of position-independence by using static archives. | 20:07:37 |
emily | cross-crate inlining only happens with explicit #[inline] annotations and I believe that the source for those goes into the rlib files(? not sure) | 20:08:21 |
emily | (also not sure if it applies to dynamic linking) | 20:08:25 |
emily | In reply to @reckenrode:matrix.org Wouldn’t that only matter for LTO, which crates have to opt into using? I know there’s a startup penalty for dynamic linking, but are there any other penalties? Darwin is PIE, so there’s no avoiding the overhead of position-independence by using static archives. AIUI there's an indirection penalty on every function call by default because of bad Linux platform decisions I believe, but like, it applies to everything we build in Nixpkgs, and we could fix that without switching away from dynamic linking if we wanted | 20:09:41 |
emily | I suspect most hot spots probably don't involve tight loops around calls that cross crates but aren't inlined | 20:10:04 |
emily | if you remember how generics in Rust work | 20:10:11 |
emily | none of that stuff is going to be a dynamically loaded function call | 20:10:18 |
emily | it'll be expanded right into the resulting executable | 20:10:31 |
Randy Eckenrode | In reply to @emilazy:matrix.org AIUI there's an indirection penalty on every function call by default because of bad Linux platform decisions I believe, but like, it applies to everything we build in Nixpkgs, and we could fix that without switching away from dynamic linking if we wanted I don’t know about Linux, but a static archive can be relinked into a dylib on Darwin. I do it in the MoltenVK derivation. Darwin is PIE, so wouldn’t you pay that penalty regardless? PIE can’t even be disabled on aarch64-darwin, and if you try to be sneaky with assembly, the linker will fail with an error if it finds instructions using absolute addressing. | 20:11:02 |
emily | so the cases where it could make a big difference seem rather marginal. you'd need a completely non-generic function that is also a hotspot but not #[inline] annotated and that you cross over constantly in a tight loop | 20:11:06 |
Randy Eckenrode | Linux may be more of an issue, but wasn’t there a desire to go PIE on Linux eventually? | 20:11:28 |