-
-
Notifications
You must be signed in to change notification settings - Fork 2
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
Feature Request: Ability to override default musl malloc implementation #30
Comments
It's a very cool idea! If we can get it working, I'd definitely be interested in the contribution. I'm honestly not sure how we'd go about this, but cc @aherrmann @fmeum who may have some ideas... In terms of the mechanics of patching musl-toolchain (I've been meaning to put together a contributing guide, and also cleaning some things up to make that guide less fiddly), I'd recommend just downloading one of the released archives, unpacking it, and making local edits to it to get things working, then we can discuss how to upstream them. But in terms of what changes you'd need to make, I'm not particularly sure :) One thing to note - if you're specifically talking about Rust, rust_binary does have a |
If we want to upstream this and the blog post really describes the simplest way to achieve this, we could do it as follows:
Happy to provide more details to anyone who is interested in working on this. |
For Rust, it should be as simple as declaring the global_allocator in the code, then instrument it with rules_rust correctly. For CC, the recommended method is to include the allocator object file when linking the binary. The linker should favor using the object file ".o" over the archives ".a". See the allocator docs discussed static linking: |
I recently added |
Apologies if this is the wrong place to post this or if this request is out of left field. Let me know if there's a better place for this or if I'm just crazy :).
As noted in https://www.tweag.io/blog/2023-08-10-rust-static-link-with-mimalloc/, the default musl malloc implementation isn't the most performant in contexts with cross-thread allocation contention. I'm in a position where I am doing almost literally what that post does (cross-compiling a Rust static binary using musl which leverages wasmtime internally) and care about multi-threaded execution performance on high core count machines.
How might one approach replacing the default musl malloc implementation with something like mimalloc as per the linked post?
I haven't yet grokked exactly how this musl cc-toolchain works, so performing archive swizzling shenanigans is beyond me just this moment ;).
The text was updated successfully, but these errors were encountered: