Skip to content

Expose mimalloc allocations for profiler interposition#50029

Closed
pablogsal wants to merge 1 commit into
apache:mainfrom
pablogsal:allocs
Closed

Expose mimalloc allocations for profiler interposition#50029
pablogsal wants to merge 1 commit into
apache:mainfrom
pablogsal:allocs

Conversation

@pablogsal
Copy link
Copy Markdown

@pablogsal pablogsal commented May 24, 2026

Memory profilers like memray couldn't track Arrow's mimalloc allocations because mimalloc is statically linked into libarrow.so and internal calls bypass PLT. This adds weak exported wrapper functions (arrow_mimalloc_allocate, arrow_mimalloc_reallocate, arrow_mimalloc_free) that route through PLT even for intra-DSO calls, enabling LD_PRELOAD-based interposition.

Includes a test that verifies the interposition mechanism works by preloading a tracking library and checking allocation counts.

Thanks for opening a pull request!

Please remove this line and the above text before creating your pull request.

Rationale for this change

What changes are included in this PR?

Are these changes tested?

Are there any user-facing changes?

This PR includes breaking changes to public APIs. (If there are any breaking changes to public APIs, please explain which changes are breaking. If not, you can remove this.)

This PR contains a "Critical Fix". (If the changes fix either (a) a security vulnerability, (b) a bug that caused incorrect or invalid data to be produced, or (c) a bug that causes a crash (even when the API contract is upheld), please provide explanation. If not, you can remove this.)

@github-actions github-actions Bot added the awaiting review Awaiting review label May 24, 2026
@github-actions
Copy link
Copy Markdown

Thanks for opening a pull request!

If this is not a minor PR. Could you open an issue for this pull request on GitHub? https://github.com/apache/arrow/issues/new/choose

Opening GitHub issues ahead of time contributes to the Openness of the Apache Arrow project.

Then could you also rename the pull request title in the following format?

GH-${GITHUB_ISSUE_ID}: [${COMPONENT}] ${SUMMARY}

or

MINOR: [${COMPONENT}] ${SUMMARY}

See also:

Memory profilers like memray couldn't track Arrow's mimalloc
allocations because mimalloc is statically linked into libarrow.so
and internal calls bypass PLT. This adds weak exported wrapper
functions (arrow_mimalloc_allocate, arrow_mimalloc_reallocate,
arrow_mimalloc_free) that route through PLT even for intra-DSO
calls, enabling LD_PRELOAD-based interposition.

Includes a test that verifies the interposition mechanism works
by preloading a tracking library and checking allocation counts.
@pablogsal
Copy link
Copy Markdown
Author

Ah i was not aware of #41128 @pitrou do yo think you can resurrect that PR, with that we can add memray support

@pablogsal pablogsal closed this May 24, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant