Skip to content

feat: Add mimalloc feature flag#32

Closed
j-g00da wants to merge 1 commit intomainfrom
j-g00da/mimalloc
Closed

feat: Add mimalloc feature flag#32
j-g00da wants to merge 1 commit intomainfrom
j-g00da/mimalloc

Conversation

@j-g00da
Copy link
Collaborator

@j-g00da j-g00da commented Jan 28, 2026

Adds option to switch memory allocator to mimalloc using a feature flag.

Disabled by default.

Adds option to switch memory allocator to mimalloc
using a feature flag.

Disabled by default.

Signed-off-by: Jagoda Ślązak <[email protected]>
@j-g00da j-g00da requested a review from link2xt January 28, 2026 19:08
@link2xt
Copy link
Contributor

link2xt commented Jan 28, 2026

Let's deploy musl version first and see if mimalloc is needed. And if needed, then it could be enabled without the feature flag, we are not going to have options to deploy different versions of malloc on chatmail anyway.

Does mimalloc actually build statically with musl target?

@j-g00da
Copy link
Collaborator Author

j-g00da commented Jan 28, 2026

Does mimalloc actually build statically with musl target?

It does

@link2xt
Copy link
Contributor

link2xt commented Jan 28, 2026

Seems we don't need it, after switch to musl memory is at ~3MB all the time instead of growing to 500 MB and staying there like it was with glibc.

@link2xt
Copy link
Contributor

link2xt commented Jan 28, 2026

Also some reference about fragmentation: https://kerkour.com/rust-jemalloc

There are also some posts about musl libc being slow in heavily threaded apps, but in case of filtermail CPU usage did not increase so it does not matter for our usage: https://nickb.dev/blog/default-musl-allocator-considered-harmful-to-performance/
Maybe it makes filtermail slower without increasing CPU usage, just by threads locking each other, but we need to measure it before trying to improve.

Does not look like adding dependency is worth it, it may even make filtermail use more than 3MB of memory.

@j-g00da j-g00da closed this Jan 29, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants