Skip to content
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

Enable frame pointer #60

Merged

Conversation

mornyx
Copy link

@mornyx mornyx commented May 11, 2022

What's changed

Update Makefile and other build scripts to enable frame pointer & re-compile Rust std.

Details

The stack backtrace implementation of pprof-rs which we currently depends on is based on libunwind, which may trigger segmentation faults in some scenarios (especially on ARM architecture).

Here are some related issues:

This PR prepares for the introduction of a new version of pprof-rs. The new pprof-rs provides frame-pointer-based stack backtrace.

More tech info is in tikv#12326 maintained by @YangKeao.

Performance overhead

Enabling the frame pointer will use the RBP/x29 register to hold the frame address, one less general purpose register means there may be a performance regression.

Here is a simple measurement. In general, the frame-pointer-based stack backtrace has no performance regression compared to the original DWARF-based stack backtrace.

In other words, for scenes with CPU Profiling (or Continuous Profiling) enabled, the overall overhead based on frame pointers is much lower than that based on DWARF. But for scenes that don't use profiling, there is a little extra overhead at all times for frame pointers.

Default behavior and manual control

There are now two additional environment variables that control compilation behavior: PROXY_FRAME_POINTER and PROXY_BUILD_STD. We set them all to 1 by default in the Makefile, which means they are enabled by default.

If you want to disable frame-pointer, please manually set the environment variable PROXY_FRAME_POINTER=0 make (this will cause CPU Profiling to get only the top function and not the full call stack after we upgrade pprof-rs).

If you want to avoid recompiling the Rust standard library, please manually set the environment variable PROXY_BUILD_STD=0 make (this will lose CPU Profiling samples related to Rust std functions after we upgrade pprof-rs).

If you avoid run make and just use cargo build, the frame pointer will not be enabled and std will not be recompiled.

Release note

None

Signed-off-by: mornyx <[email protected]>
Copy link
Member

@CalvinNeo CalvinNeo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lgtm

@CalvinNeo CalvinNeo merged commit 2cf6ff7 into pingcap:raftstore-proxy-6.0-try May 12, 2022
@mornyx mornyx deleted the tiflash-frame-pointer-6.0 branch May 25, 2022 04:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants