Skip to content

[WIP] Mimalloc Integration - #212

Draft
elazaro-riverside wants to merge 58 commits into
mainfrom
mimalloc_integration
Draft

[WIP] Mimalloc Integration#212
elazaro-riverside wants to merge 58 commits into
mainfrom
mimalloc_integration

Conversation

@elazaro-riverside

@elazaro-riverside elazaro-riverside commented Jun 1, 2026

Copy link
Copy Markdown
Collaborator

This PR contains changes to libresolve to investigate alternative approaches to allocation metadata lookup. The motivation behind this change is to investigate the cost of retrieving metadata for registered dynamic allocations. The current lookup implementation searches a BTreeMap containing registered heap allocations. This lookup introduces overhead that can become significant in applications that perform frequent heap accesses or contain a large number of dynamic allocations.

To mitigate this cost, we have started investigating approaches for reducing the overhead of allocation metadata lookups. The mimalloc allocator has excellent performance characteristics, and one of its notable properties is its ability to locate allocation metadata in O(1) time from an allocation address. At a high level, mimalloc organizes memory into segments, pages, and fixed-size blocks, allowing the page containg the pointer to be located directly from its address. The corresponding page metadata then provides information such as the page start address and block size, which can be used to determine the bounds of the allocation.

@elazaro-riverside elazaro-riverside added enhancement New feature or request libresolve Related to libresolve component labels Jun 1, 2026
// * - size: number of bytes to copied
// * @return - pointer to the copied string
// * NOTE: Read this link to understand the nature of strdup & strndup
// * https://pubs.opengroup.org/onlineptrpubs/9699919799/functions/strdup.html

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Seems like this change was unintentional...

@elazaro-riverside
elazaro-riverside force-pushed the mimalloc_integration branch 3 times, most recently from 780db71 to 2c1e515 Compare June 15, 2026 14:56
Ethan Lazaro added 20 commits August 28, 2026 10:11
…odifications to the Dockerfile and cargo files to ensure mimalloc source is correctly linked with libresolve.
…alloc archive to cargo so that downstream tests pass.
… compare the mimalloc approach to strict shadow object bounds approach.
…ncy. Added debugging statement and logic to use libc free if the allocation is not from mimalloc.
Ethan Lazaro added 26 commits August 28, 2026 10:33
…f the pointer is owned by a mimalloc allocation.
… the pointer is within a mimalloc-owned mem region.
…to return null pointers for pointers that are not allocated by mimalloc.
… in image-histogram is an interior pointer.
…mmented code from runtime functions, and adding info!() to debug allocation bounds returned from mimalloc.
@elazaro-riverside

elazaro-riverside commented Sep 3, 2026

Copy link
Copy Markdown
Collaborator Author

NOTE: Mimalloc cannot be mixed with other allocators. This includes external dependencies!
mimalloc-override.h

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

Labels

enhancement New feature or request libresolve Related to libresolve component

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants