Skip to content

Draft: Compile Ruby with -fno-omit-frame-pointer

Matthias Käppler requested to merge mk-ruby-no-omit-frame-pointer into master

This allows performance analysis tools to reconstruct function names. For instance, when trying to profile a Rails console started from the GCK Ruby, which runs in a container based on this image, I see:

carbon# profile-bpfcc -U -p $(pgrep -f 'ruby /home/git/gitlab/bin/rails console')                     
Sampling at 49 Hertz of PID 11904 by user stack... Hit Ctrl-C to end.
^C
    vm_exec_core
    [unknown]
    -                ruby (11904)
        1

    vm_exec_core
    [unknown]
    [unknown]
    [unknown]
    -                ruby (11904)

It looks like Ruby only includes frame pointers when building on Windows: https://github.com/ruby/ruby/blob/ea39955e23f82d05c0e1a5b0933a78fc4245409f/configure.ac#L811-L817

According to http://www.brendangregg.com/perf.html:

Always compile with frame pointers. Omitting frame pointers is an evil compiler optimization that breaks debuggers, and sadly, is often the default. Without them, you may see incomplete stacks from perf_events, like seen in the earlier sshd symbols example.

As regards performance impact, every source I've read suggests that the benefits of increased insight far outweigh the performance drawbacks. Here is a very good summary of the topic: https://stackoverflow.com/questions/13006371/does-omitting-the-frame-pointers-really-have-a-positive-effect-on-performance-an

We already made the same change to Omnibus images in omnibus-gitlab!4030 (merged).

Edited by Matthias Käppler

Merge request reports