-
-
Notifications
You must be signed in to change notification settings - Fork 236
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
feat: use mimalloc instead of musl's mallocng for static builds #666
Conversation
Oho, gonna test this one real quick. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Appears to be much faster.
// libc:
[2024-03-15T17:58:12.419081+00:00] alert: Completed in 15.709 seconds {"process_id":87753,"memory_peak_usage":"114 MB"}
// this patch
[2024-03-15T18:11:51.670770+00:00] alert: Completed in 40.284 seconds {"process_id":62743,"memory_peak_usage":"110 MB"}
// vanilla musl
[2024-03-15T18:15:36.365410+00:00] alert: Completed in 51.751 seconds {"process_id":4149,"memory_peak_usage":"110 MB"}
That being said, I did run into some issues with some caddy modules that needed to be disabled or I would get segfaults randomly.
I also get random segfaults with the OpenSSL extension. This isn't ready for prime time 😅 |
Could it be the libraries are linked without mimalloc? |
@withinboredom could you give more details on the modules sefgfaulting in your tests? It looks like the OpenSSL issue may not be related to malloc after all. |
@dunglas why can't glibc be used there even if it means shipping something else than Alpine Linux? Or alternatively wouldn't it work with gcompat? |
@theofidry I'm not sure to follow. We provide glibc builds too (in the Docker images), but glibc doesn't support creating static builds. We have to use musl for that. See also: crazywhalecc/static-php-cli#376 |
Just FYI lots of openssl tests fails in Alpinelinux with openssl (even years ago with libressl) Current set of disabled openssl tests can be found at repo
|
Checked where alternate *malloc is used in Alpinelinux
|
I'll give this a test again this weekend. |
@withinboredom what benchmark were you running in #666 (review) ? Is there a way I could reproduce this ? In my benchmarks the difference between glibc and musl are not as dramatic (and alternative allocators also don't do as much difference) |
It's actually a benchmark of an app I'm building. It results in a lot of syscalls deep under the hood (lots of file access, shm, proxy generation, etc). |
I added a new experimental flag to build using mimalloc and added a CI pipeline to build a mimalloc variant automatically. |
The default musl allocator is slow for multi-threaded apps such as FrankenPHP and triggers weird bugs such as php/php-src#13648.
The trickery in this patch (massively inspired by this article by Tweag) replaces the musl allocator by https://github.com/microsoft/mimalloc, a fast allocator created by Microsoft.
Hopefully, this will also help for #481 (comment).