3 ms·
Making code less efficient, mainly for the sake of some stupid tool (and I use that term in both meanings...), and one that's supposed to help improve efficienc
by userbinator 4y ago
Making code less efficient, mainly for the sake of some stupid tool (and I use that term in both meanings...), and one that's supposed to help improve efficiency? That's incredibly ironic.
The thing is that DWARF unwinding (the only userspace option that doesn’t use frame pointers) is really unreliable. In fact it has such serious problems that it’s not that usable at all.
The real solution to things like this is to improve the debugging information so that return addresses can be tracked more accurately, but no one seems willing to do that work. It reminds me of encountering "value optimised out" when I can clearly see where the value is if I inspect the Asm.
Explicit constant frame pointers are almost an anachronism from an era when compilers were far worse at code generation. It seemed like a good idea at the time because it made compilers simpler, and of course on 16-bit x86 bp was the only other register that defaulted to the stack segment and [sp+nn] didn't exist. Those points are not really relevant anymore with 32-bit and 64-bit x86 using a flat memory model. Sometimes the extra byte needed for esp/rsp-relative access is worse, sometimes the extra register consumed by ebp/rbp-relative access is worse. It's really something that needs to be decided case-by-case like a intelligent Asm programmer would.
- vbezhenar 4y agoPeople who build distros and people who fix those low-level tools are different sets of people, I guess. So they have to build distro using tools available today. If tomorrow situation changes, they'll probably revisit this decision.
- justinclift 4y ago> The real solution ... Is the "real solution" a case of letting "the perfect" get in the way of "good enough" (sic)?
- Dylan16807 4y agoJust keeping track of the frame pointer is probably not the perfect. In fact it might be the exact opposite. We have very complicated mechanisms that try to keep track of every possible optimization. Maybe that effort is getting in the way of a solution that slightly limits frame pointer optimization but easily figures out the value in all situations. So because the "perfect" mechanism is having implementation problems, and nobody has tried to make the "good" mechanism, we're stuck with the very mediocre "reserve a register".
- nemetroid 4y ago> The real solution to things like this is to improve the debugging information so that return addresses can be tracked more accurately, but no one seems willing to do that work. It reminds me of encountering "value optimised out" when I can clearly see where the value is if I inspect the Asm. As someone who’s excited about Fedora’s change, I agree. But while waiting for that to happen, I want to have a good debug/tracing experience, which currently only frame pointers can provide.
- quotemstr 4y ago> while waiting for that to happen, I want to have a good debug/tracing experience, which currently only frame pointers can provide What's the rush? We've lived without adequate unwinding this long. We can afford to take a little bit more time and do it right.
- rwmj 4y agoWe really cannot. We were losing larger optimisations all the time by not having frame pointers.
- mort96 4y agoWhat optimizations are impossible without a frame pointer?
- rwmj 4y agoAny that involve looking at the whole system with perf, especially where you don't want to or cannot ask the user to recompile the entire Linux distro before collecting the data. So pretty much anything that isn't a microbenchmark.
- josephcsible 4y ago> It reminds me of encountering "value optimised out" when I can clearly see where the value is if I inspect the Asm. Can you share an example of when that happens?
- userbinator 4y agoIt happens all the time. There are occasional HN discussions on it, e.g. https://news.ycombinator.com/item?id=33166188 https://news.ycombinator.com/item?id=33166188
- rcxdude 4y agoIt's so common I'm often suprised when I can get a value out of gdb. Especially for function arguments and loop indexes.
- AshamedCaptain 4y ago> In fact [DWARF] has such serious problems that it’s not that usable at all. This is likely wrong. The kernel does not have a DWARF unwinder. He's probably just desymbolizing a poor stack trace taken by the kernel chasing ebps, not unwinding it with DWARF.
- linuxftw 4y agoPart of the earlier discussions on this topic, the pro-FP side makes the argument that if FP are disabled by default, you need to recompile a ton of the distro to enable them. If they're enabled by default, and there's a particular library you want to disable them for performance reasons, that's relatively trivial.