-
Notifications
You must be signed in to change notification settings - Fork 9
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
Improve global allocator documentation #18
Comments
Hi!
Regarding MiMalloc, I briefly looked into trying to implement platform-specific support for fast SMP allocation a while back, but I came away with the impression that this allocator hasn't been designed from the ground up in a way that would make it a competitive choice for multithreaded applications. Doing so would be a lot of work, only to enter a far more competitive niche. If you're developing an application that falls within its strengths, please use it instead. It looks very impressive. If, for example, you're interested in OSdev and getting a project like Talc to efficiently integrate with your own threading system, besides keeping an allocator per-CPU, I'm interested in working on perhaps better-integrating something like this, so please open an issue if you're interested in more support from Talc for something like that. |
Regarding 2, this example should work without nightly, as it's not using the nightly-gated functions (which is just the *mut [T] -> Span conversions due to rust-lang/rust#71146 or rust-lang/rust#81513) I believe I should clarify this in the Stable Rust section. Burying this in the changelog isn't ideal. |
That might be helpful? 👍 I don't have a need for Wasn't particularly difficult to realize from the failure that I needed to bring in the dep:
I'm probably doing something wrong then? [dependencies]
talc = { version = "3.1.1", default-features = false, features = ["lock_api"] }
spin = { version = "0.9.8", default-features = false, features = ["lock_api", "spin_mutex"] } $ cargo --version
cargo 1.74.0 (ecb9851af 2023-10-18)
$ cargo run
Compiling hello_world v0.1.0 (/tmp/hello_world)
error[E0554]: `#![feature]` may not be used on the stable release channel
--> src/main.rs:1:1
|
1 | #![feature(const_mut_refs)]
# Removed feature attribute
$ cargo run
Compiling hello_world v0.1.0 (/tmp/hello_world)
error[E0658]: mutable references are not allowed in statics
--> src/main.rs:12:57
|
12 | Talc::new(unsafe { ClaimOnOom::new(Span::from_array(&mut ARENA)) }).lock();
| ^^^^^^^^^^ |
I'll go ahead with adding a clarifying comment for the spin dependency.
You are absolutely correct, my bad! Here's my workaround. Indeed it's nonobvious. Here's what I'll update the example to: Span::from_base_size(&ARENA as *const _ as *mut _, 10000)
// Span::from_array(&mut ARENA) - better but requires unstable #[feature(const_mut_refs)] It's not pretty but it's the best I know of. (Unfortunately I'll close this once I publish these changes to the project, probably quite soon. Thanks for reaching out! |
After more delay than it should've been, the changes are in and a new minor version has been released. Thanks once again. |
The current example:
spin
?TalckWasm
?I was curious how
talc
might compare tomimalloc
:But perhaps they serve different audiences 😅
EDIT: I compared the nightly toolchain (with this example test that shows degraded perf with multi-thread on musl) between
talc
andmimalloc
and while they were similar on single thread (~300ms
), multi-thread had a notable difference (10 threads):mimalloc
: ~45ms (musl is ~330ms withoutmimalloc
)talc
: ~800msI noticed
talc
emphasizing single-thread usage, and I was curious how it compared in a multi-thread context. I guess thetalc
allocator spin mutex would have been blocking for multi-thread to slow it down to ~2.5x.The text was updated successfully, but these errors were encountered: