Live data from Hacker News

Ubuntu 24.04 LTS will enable frame pointers by default

ubuntu.com

21–30 of 121 posts

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#21

For the layman, what does this mean?

We wrote pretty extensively about what was needed to be able to profile things without frame pointers [1]. It's still possible at less than 1% overhead with the right set of technologies, but frame pointers unwinding is virtually free.

[1] https://www.polarsignals.com/blog/posts/2022/11/29/dwarf-bas...

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#22

hasn't this already been in fedora for almost a year?

I believe so, I remember a fair amount of hubbub over it. Can't say it's been useful here, any development I do is miles away from this. It hasn't hurt either so... cool, I guess Call me pessimistic, but I'm not convinced this being the default will lead to more profiling. There's plenty that could be done without this, that isn't, so I'm not buying it.

While profiling benefits immensely, imagine all the other ramifications. Cheap tracing of MySQL, postgres, or anything else using bpftrace or any other bcc tools. Getting stack traces of processes that are already core dumping...

Profiling is one part, but the debuggability this enables is going to be huge in the long term I predict.

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#24
post #6
post #2

Frame pointers are such a destructive micro-optimization to omit by default, I am beyond excited about this collaboration with the folks at Canonical to make Ubuntu debuggable by default!

This option was almost certainly a holdover from the bad old 32-bit x86 days, when disabling frame pointers gave you a seventh valuable general-purpose register. It's no longer beneficial on x86_64 -- even with rbp locked down, you still have fourteen registers there.

and 14 registers should be enough for everyone!

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#25

Pro tip for performance optimisation in Ubuntu (you also gain more RAM): Remove snap (or choose a Ubuntu distro variant like Pop OS without snap)

Is that even practical nowadays? My understanding is that snap is deeply integrated. Don't some apt packages point to their snap variants?

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#26

For the layman, what does this mean?

There are two key effects of this decision.

The first effect is that it makes one additional general-purpose integer register unavailable for use for code. x86-64 has 16 general-purpose registers, but one of these is the stack pointer and basically can't be used for any other purpose; this would add a second reserved register for the frame pointer. This effect may cause slowdowns if the 15th register was critical for performance.

The second effect is on the ability to identify (and potentially unwind) the stack trace. With frame pointers, the pseudocode for computing a stack trace is essentially:

  do
    load return address, previous frame pointer from current frame pointer
    print return address
    move previous frame pointer into current frame pointer
  until current frame pointer is invalid
Without frame pointers, the way you have to do this procedure is:

  while current address has corresponding entry in unwind table:
    parse unwind table entry to find a program to run
    run this program on the current frame to generate return address
    print return address
    move return address to current address
It turns out that there is a full Turing-complete program described in the unwind tables to be able to generate a return address. This makes unwinding quite expensive, and also can create lots of security headaches if you want do something like unwind in the kernel (since the unwind table is arbitrary user code!). It can also be pretty unreliable at times, especially in cases where your program crashed due to stack smashing so that you have to expect that the data being randomly overwritten with garbage and thus horrifically inaccurate.

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#27
post #6
post #2

Frame pointers are such a destructive micro-optimization to omit by default, I am beyond excited about this collaboration with the folks at Canonical to make Ubuntu debuggable by default!

This option was almost certainly a holdover from the bad old 32-bit x86 days, when disabling frame pointers gave you a seventh valuable general-purpose register. It's no longer beneficial on x86_64 -- even with rbp locked down, you still have fourteen registers there.

Yeah, back in the 32 bit days -fomit-frame-pointer was the only optimization you could count on to really make a difference. It wasn't small either, often 10-15% speedup. No other flag on gcc would make even a full percentage difference in my testing.

The Amd64 architecture fixed the underlying problem, so this is pretty much just a holdover. I'm surprised they even enabled it by default.

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#28

Pro tip for performance optimisation in Ubuntu (you also gain more RAM): Remove snap (or choose a Ubuntu distro variant like Pop OS without snap)

Is that even practical nowadays? My understanding is that snap is deeply integrated. Don't some apt packages point to their snap variants?

It’s still possible, although increasingly annoying.

I believe Firefox now points to its snap variant, which I discovered when it broke a bunch of my browser extensions. Switching to the official Mozilla PPA was easily enough, but left a bad taste; if Canonical continues down the route of silently nudging users onto snap, I’ll probably switch to Debian.

(I have no particular opinions about snap itself, other than that it seems poorly documented and doesn’t adhere to the “do what I say” philosophy when it’s secretly injected into apt.)

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#29

hasn't this already been in fedora for almost a year?

Yeah. To be fair there is a stronger argument for it being enabled in fedora than an LTS release (RHEL or Ubuntu) since it has more cutting edge software that needs more frequent debugging, is less likely to be used in production where the (minor, but uneven) performance hits may matter, and has so many upstream developers using it as their daily driver.

Re: Ubuntu 24.04 LTS will enable frame pointers by default

#30
I somewhat painstakingly figured this out the hard way pulling core dumps off of embedded linux devices that gdb had a hard time working with. At the time I was like whew why is omitting frame pointers the default at all in so many places when it didn't seem to make a measurable difference in the performance of the software. I guess it's just vestigial these days and yes please use a compiler flag like this when it measurably makes sense. Making debugging simpler for the rest of us is the way to go.
Post reply on HN