by masklinn · 3y ago · 0 comments
Not really. Lots of rust users come from high level languages so when people come in and complain about rust being unexpectedly slow allocation issues are in the top 5 at least. It’s incredible how shit the standard allocators are in almost all systems.
Are too
> They are supposed to be general-purpose allocators with requirements that may not match your workload.
I don’t think they match any workload which exists anywhere anymore. Possibly their workload existed back in the 90s.
Jemalloc is also a general-purpose allocator, it‘s the one freebsd uses.
This is not inevitable, platforms could provide allocators which are less awful. Obviously they can’t be as fast as specialised runtime facilities but when you see the gains many applications get by just swapping in jemalloc or some such…
Huh. I’ve seen lots of people write slow Rust code because they didn’t realize there were allocations. But the complaint is usually “my rust program is only 5x faster than my equivalent python program instead of 100x how come”?
Can you point out some good blog posts about Rust or C++ being slower than a “basic runtime” due to inferior allocator?
It’s not the beginner’s fault that most system allocators suck so hard you must do your utmost to limit their use.
Escape analysis as you’re alluding to isn’t needed in this model because the amount of times this helps you (ie you put it on the heap but the compiler can figure out it can live on the stack) is about 0. You need escape analysis in managed memory languages where everything is nominally a heap allocation and the compiler is responsible for clawing back performance through escape analysis.
That said, there are a few reasons beyond just that. For the primary sources: https://github.com/rust-lang/rust/issues/36963