Skip to content

gh-152769: Enable perf trampoline on Alpine#152774

Open
weixlu wants to merge 1 commit into
python:mainfrom
weixlu:perf
Open

gh-152769: Enable perf trampoline on Alpine#152774
weixlu wants to merge 1 commit into
python:mainfrom
weixlu:perf

Conversation

@weixlu

@weixlu weixlu commented Jul 1, 2026

Copy link
Copy Markdown
Contributor

Proposal of change

As mentioned in #152769, perf can‘t collect Python function-level hotspot info on Alpine Linux because perf trampoline support is not enabled there.

The trampoline is a CPU-architecture-specific feature and has little to do with OS or libc. Therefore, we can simply modify configure to reuse the same trampoline implementation as glibc.

Test results

I ran the tests on the following three platforms:

  • Alpine 3.22.4, musl 1.2.5, x86_64 (matching the buildbot env)
  • Alpine edge, musl 1.2.6, x86_64 (latest version)
  • Alpine 3.22.4, musl 1.2.5, aarch64 (specifically ARMv9 Neoverse N2)

The three profiling-related tests now pass on all of these platforms:

test_perf_profiler
test_perfmaps
test_samply_profiler

Before this PR, these tests were skipped.

I also manually collected profiling data with perf and confirmed that Python-level functions appear in the profiling output.

How to reproduce

  1. When running Alpine in a container, note that the container needs to be started with the additional --privileged option.

  2. Apart from build dependencies, install perf and samply. samply needs to be built with Rust:

apk add perf rust cargo
export PATH="$HOME/.cargo/bin:$PATH"
cargo install --locked samply
  1. Run the tests:
./python -m test test_perf_profiler test_perfmaps test_samply_profiler
  1. To manually check profiling data, refer to the scripts described in Lack of perf support on Alpine Linux #152769.

@weixlu

weixlu commented Jul 2, 2026

Copy link
Copy Markdown
Contributor Author

@vstinner Hi, this is the PR fixing perf trampolines on musl. Could you please take a look?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant