not-matthias · GitHub

Bug report

Bug description:

See: mstange/samply#826 and mstange/linux-perf-data#27

Reproduction with samply

fib.py:

def fib(n):
    if n < 2:
        return n
    return fib(n - 1) + fib(n - 2)
print(fib(36))

Works: Just using the perf-map resolves py::fib:

PYTHONPERFSUPPORT=1 samply record -- python3.15 fib.py

However, when emitting the jitdumps, we see a ton of unresolved 0x... frames and no py::fib:

PYTHON_PERF_JIT_SUPPORT=1 samply record -- python3.15 fib.py

The issue

CPython 3.15 introduces Jitdump support on MacOS: #136461

This PR also changed the struct layout:

#if defined(__APPLE__)
uint64_t thread_id; // Thread ID where code was generated
#else
uint32_t thread_id; // Thread ID where code was generated
#endif
#if defined(__APPLE__)
    uint64_t thread_id;      // Thread ID where code was generated
#else
    uint32_t thread_id;      // Thread ID where code was generated
#endif

This is not compatible with the original linux perf data specification, which almost all profilers/tools rely on. I highly recommend fixing this, otherwise profilers won't be able to take advantage of jitdumps.

CPython versions tested on:

3.15

Operating systems tested on:

macOS

Linked PRs

Read the original on github.com ↗