Add and use snmalloc, mimalloc for allocation performance #14899

Open
opened 2026-01-31 04:22:44 +00:00 by claunia · 4 comments
Owner

Originally created by @WSLUser on GitHub (Aug 18, 2021).

Description of the new feature/enhancement

Github randomly revealed a project from Microsoft that upon investigation seems like it would be pretty useful here to possibly boost performance for allocations. https://github.com/microsoft/snmalloc

Proposed technical implementation details (optional)

Originally created by @WSLUser on GitHub (Aug 18, 2021). <!-- 🚨🚨🚨🚨🚨🚨🚨🚨🚨🚨 I ACKNOWLEDGE THE FOLLOWING BEFORE PROCEEDING: 1. If I delete this entire template and go my own path, the core team may close my issue without further explanation or engagement. 2. If I list multiple bugs/concerns in this one issue, the core team may close my issue without further explanation or engagement. 3. If I write an issue that has many duplicates, the core team may close my issue without further explanation or engagement (and without necessarily spending time to find the exact duplicate ID number). 4. If I leave the title incomplete when filing the issue, the core team may close my issue without further explanation or engagement. 5. If I file something completely blank in the body, the core team may close my issue without further explanation or engagement. All good? Then proceed! --> # Description of the new feature/enhancement <!-- A clear and concise description of what the problem is that the new feature would solve. Describe why and how a user would use this new functionality (if applicable). --> Github randomly revealed a project from Microsoft that upon investigation seems like it would be pretty useful here to possibly boost performance for allocations. https://github.com/microsoft/snmalloc # Proposed technical implementation details (optional) <!-- A clear and concise description of what you want to happen. -->
claunia added the Help WantedIssue-TaskProduct-MetaArea-Performance labels 2026-01-31 04:22:45 +00:00
Author
Owner

@WSLUser commented on GitHub (Aug 20, 2021):

https://github.com/microsoft/mimalloc is more general purpose while snmalloc is for message-passing specifically. Use both as needed in places where allocations need to occur and can't simply be removed.

@WSLUser commented on GitHub (Aug 20, 2021): https://github.com/microsoft/mimalloc is more general purpose while snmalloc is for message-passing specifically. Use both as needed in places where allocations need to occur and can't simply be removed.
Author
Owner

@WSLUser commented on GitHub (Aug 20, 2021):

So it looks all we need to do here is add it to the build steps. https://github.com/contour-terminal/contour/pull/341/ shows how it's done for cmake. MSVC makes it bit more difficult as you need to ensure build steps are done properly in order and while I'd like to take a stab at this, I'm concerned about messing the build up trying to add this. I'd start with mimalloc first in this case and follow all of it's recommendations for flags for C++:

For best performance in C++ programs, it is also recommended to override the global new and delete operators. For convience, mimalloc provides mimalloc-new-delete.h which does this for you -- just include it in a single(!) source file in your project. In C++, mimalloc also provides the mi_stl_allocator struct which implements the std::allocator interface.

Also see https://github.com/microsoft/mimalloc#override-on-windows for Windows specific optimizing.

@WSLUser commented on GitHub (Aug 20, 2021): So it looks all we need to do here is add it to the build steps. https://github.com/contour-terminal/contour/pull/341/ shows how it's done for cmake. MSVC makes it bit more difficult as you need to ensure build steps are done properly in order and while I'd like to take a stab at this, I'm concerned about messing the build up trying to add this. I'd start with mimalloc first in this case and follow all of it's recommendations for flags for C++: > For best performance in C++ programs, it is also recommended to override the global new and delete operators. For convience, mimalloc provides mimalloc-new-delete.h which does this for you -- just include it in a single(!) source file in your project. In C++, mimalloc also provides the mi_stl_allocator struct which implements the std::allocator interface. Also see https://github.com/microsoft/mimalloc#override-on-windows for Windows specific optimizing.
Author
Owner

@WSLUser commented on GitHub (Aug 20, 2021):

@skyline75489 Are you comfortable with messing with the build steps to see how much of a boost we get in Process Explorer?

@WSLUser commented on GitHub (Aug 20, 2021): @skyline75489 Are you comfortable with messing with the build steps to see how much of a boost we get in Process Explorer?
Author
Owner

@lhecker commented on GitHub (Aug 21, 2021):

Chester is unfortunately currently already preoccupied.
Since the benefits in Contour were rather significant I'll look into this in his stead.

@lhecker commented on GitHub (Aug 21, 2021): Chester is unfortunately currently already preoccupied. Since the benefits in Contour were rather significant I'll look into this in his stead.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/terminal#14899