Re: Do we use -fno-omit-frame-pointers by accident?

Martin Cracauer <[email protected]> Fri, 19 Jun 2026 11:24:36 -0400
Newsgroups gmane.os.freebsd.devel.hackers
Message-ID <[email protected]>
Martin Cracauer wrote on Thu, Jun 18, 2026 at 04:51:41PM -0400: 
> I was about to propose on BSDCan to turn on -fno-omit-frame-pointer
> for the base system userland and most ports.[*]
> 
> So I went benchmarking the performance impact.
> 
> I discovered that CFLAGS+=-fno-omit-frame-pointer changes nothing
> about our binaries and shared libraries.  CFLAGS+=-fomit-frame-pointer
> makes them a little smaller.  So it looks like we default to having
> frame pointers... somehow.  I verified in the compiler stdout that the
> flags I set are in fact in effect.
> 
> Sizes for 16-current 283959bbe0863917c4fc3200a92d1055a4c89bdc /bin/sh:
> 
>    text    data     bss     dec     hex filename
> - default: 
>  164503    3712    5520  173735   2a6a7
> - -fomit-frame-pointer
>  163831    3712    6192  173735   2a6a7
> - -fno-omit-frame-pointer
>  164503    3712    5520  173735   2a6a7

Performance measurements confirm.  Userland (including llvm) compiled
with -fomit-frame-pointer is 2% faster for `make buildworld
buildkernel`.  2% is generally assumed to be the average slowdown from
frame pointers.

-fomit-frame-pointer:
45:50.00 2750.00 real 60147.28 user 1657.93 sys 2247% CPU
default freebsd:
46:29.94 2789.94 real 61529.67 user 1629.37 sys 2263% CPU

I conclude that we indeed include frame pointers for userland, but I
can't see where we turn that on.

Martin

> [*] The reason why I bring this up now is that Ubuntu is doing the
> work for use of determining which pieces of software have actually too
> high overhead with FPs.  Such as the CPython interpreter.  Depending
> on further benchmarking the base userland this changes the
> effort/benefit balance.
> 
> More words here:
> https://docs.google.com/presentation/d/17AGf6a0IxIzqcgd4-5FWdQhLzBV9DfLEhNTm-xL0vyc/edit?usp=sharing
> 
> Martin
> -- 
> %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
> Martin Cracauer <[email protected]>   http://www.cons.org/cracauer/

-- 
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
Martin Cracauer <[email protected]>   http://www.cons.org/cracauer/