Skip to content

gh-136459: Add perf trampoline support for macOS #136461

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

Merged
merged 11 commits into from
Jul 22, 2025
Prev Previous commit
Next Next commit
Do not mmap the jitdump file on macOS
On macOS, we don't need to call mmap because samply has already detected
the file path during the call to `open` before (it interposes `open` with
a preloaded library), and because the mmap call can be slow.
  • Loading branch information
canova committed Jul 17, 2025
commit dc54659a2fb0eb0ed1883b8a0066834136ccbc97
5 changes: 5 additions & 0 deletions Python/perf_jit_trampoline.c
Original file line number Diff line number Diff line change
Expand Up @@ -1055,6 +1055,10 @@ static void* perf_map_jit_init(void) {
return NULL; // Failed to get page size
}

#if defined(__APPLE__)
// On macOS, samply uses a preload to find jitdumps and this mmap can be slow.
perf_jit_map_state.mapped_buffer = NULL;
#else
/*
* Map the first page of the jitdump file
*
Expand All @@ -1077,6 +1081,7 @@ static void* perf_map_jit_init(void) {
close(fd);
return NULL; // Memory mapping failed
}
#endif

perf_jit_map_state.mapped_size = page_size;

Expand Down