I use Jemalloc in a specific project because it keeps per-thread allocation counters, so I can both monitor how much memory a thread is actively using (and how much it has allocated and deallocated), and I can limit it.
This is an incredible feature, and it's a hard requirement for this particular project, and a good fit because the workloads map to threads. Manually managing such counters with the standard Rust allocator is not a practical option.
But one problem I see with the new Rust allocators is that it doesn't seem like there's any kind of thread-local allocator? If so, you have to pass an allocator through every nook and cranny of the system as opposed to just riding on the thread context.
Even if the allocator is available as a "global" thread-local variable, which might be an option, that's a lot of places that need to be updated with .new_in(). And you have to introduce some kind of linting rule that rejects any code that isn't using the custom allocator.
I don't suppose a solution to this problem exists or is planned?
Not sure I understand what you're looking for exactly, but couldn't you just wrap a thread-local allocator (the design you're talking about) in a global allocator by referencing a static thread-local in that static global allocator? Then you wouldn't have to .new_in(), but you would still have thread-local allocation.
I'm not saying this is a good idea, just that it seems like Rust does maybe accommodate what you're talking about already.
I don't think it's possible to implement thread-local “global” allocators. Since you need to use the same allocator to allocate and deallocate memory, transferring such objects across threads could transfer them to a thread without the right allocator — any data allocated with that allocator would need to be !Send, but the type system doesn't allow types to vary like that based on what allocator is active.