4 ms·
Can anyone link me to a breakdown of how jemalloc fairs against system allocators wrt Rust? I was of the impression that the standard system allocators had wors
by weberc2 8y ago
Can anyone link me to a breakdown of how jemalloc fairs against system allocators wrt Rust? I was of the impression that the standard system allocators had worse fragmentation properties? Is that not true, or is the idea that if you care about fragmentation, you should opt into jemalloc?
- jashmatthews 8y agoRust doesn't have a runtime so this is almost completely application dependent.
- saagarjha 8y agoWhat kinds of things does jemalloc perform better in? What are its "weaknesses"?
- timClicks 8y agojemalloc is a strong memory allocator. But I expect that the team felt that most applications don't need to ship their own memory allocator. An issue that Rust has had to overcome is that it produces bloated binaries by default. Hello World type applications are hundreds of kilobytes long, because they ship jemalloc and libunwind. Removing one of those helps.
- jashmatthews 8y agoFor example, jemalloc 3.x reduces memory usage of CRuby by ~50% and increases throughput by ~10%. It also makes an enormous difference with KV stores like Redis so it's compiled in by default. Weakness is basically binary size and code complexity.
- pantalaimon 8y agoWhy is jemalloc not included in glibc then?
- jashmatthews 8y agojemalloc is the default allocator on FreeBSD. glibc uses ptmalloc for historical reasons.
- jabl 8y agoThere was a mention somewhere that rustc (the compiler itself) still uses jemalloc, glibc 2.24(?) was about 10% slower. Compilers tend to use a lot of small allocations, so most code probably is less affected than that. I think the big selling point of jemalloc when it appeared was that it was much better for multithreaded applications. But since then glibc has improved a lot in this area, and nowadays has a similiar design with per-thread pools etc.