Skip to content

Build Python with frame pointers (-fno-omit-frame-pointer) #96174

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
tiran opened this issue Aug 22, 2022 · 7 comments
Open

Build Python with frame pointers (-fno-omit-frame-pointer) #96174

tiran opened this issue Aug 22, 2022 · 7 comments
Labels
build The build process and cross-build performance Performance or resource usage type-feature A feature request or enhancement

Comments

@tiran
Copy link
Member

tiran commented Aug 22, 2022

Feature or enhancement

I propose to build CPython with -fno-omit-frame-pointer and -mno-omit-leaf-frame-pointer on compilers that support these options, at least on Linux with GCC and clang on platforms that support perf trampoline (#96143).

Pitch

The feature is needed for #96143 "Allow the linux perf profiler to see Python calls". Otherwise perf won't be able to reconstruct the call frames and perf report output isn't helpful.

Previous discussion

The feature change proposal https://fedoraproject.org/wiki/Changes/fno-omit-frame-pointer explains the usefulness of frame pointers in great detail. Code without frame pointers can be slightly more efficient because it does not have to safe a register on function call and it can repurpose the register for other uses. The potential performance impact is discussed in the Fedora change proposal, too. tl;dr Fedora testing has not shown any significant impact.

@tiran tiran added the type-feature A feature request or enhancement label Aug 22, 2022
@tiran
Copy link
Member Author

tiran commented Aug 22, 2022

CC @pablogsal @gpshead @markshannon

@mdboom mdboom added the performance Performance or resource usage label Aug 22, 2022
@mdboom
Copy link
Contributor

mdboom commented Aug 22, 2022

It wouldn't hurt to run this change through pyperformance to help confirm the lack of performance impact.

@encukou
Copy link
Member

encukou commented Aug 22, 2022

Please don't trust the unapproved Fedora change proposal too much. Especially its performance numbers: it seems that the flag was only enabled for a small subset of code when they were made.

@pablogsal
Copy link
Member

Idea: we could enable it by default and drop it with --enable-optimizations

@gpshead
Copy link
Member

gpshead commented Aug 22, 2022

Idea: we could enable it by default and drop it with --enable-optimizations

While I laughed when I read it, I'd actually be fine with that. We tell people to use that for the best speed. Linux distro packaging setups either use that or do an equivalent on their own at which point they'd need to adopt adding an explicit -fomit-frame-pointer to their custom build, but that is entirely up to them to manage.

This is one of those compiler flags that makes code execution easier to passively analyze but always costs a little performance. The more registers the less impact on any given platform. ie: x86_64 should feel it more than ARM.

We still build most everything at work with frame pointers.

@pablogsal
Copy link
Member

Also, the pitch should be about unwinders in general, not only the perf work. Perf is orders of magnitude slower without frame pointers and so is any other unwinder (like libunwind). Having to parse dwarf to unwind is super heavy on I/O and CPU. Everywhere this is discussed the pitch is to sacrifice just a tiny bit of perf for better debugging and profiling experience

@thesamesam
Copy link
Contributor

There's been a lot more discussion on the Fedora thread (https://lists.fedoraproject.org/archives/list/[email protected]/thread/OOJDAKTJB5WGMOZRXTUX7FTPFBF3H7WE/) as of the last few days - worth reading.

As for Python, if it decides to do it, please restrict it to 64-bit arches (ideally just amd64 for now until others have been analysed).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
build The build process and cross-build performance Performance or resource usage type-feature A feature request or enhancement
Projects
None yet
Development

No branches or pull requests

7 participants