4 ms·
A lot of people underestimate the performance impact of malloc(). It is dog slow. In addition if you use a poor malloc() implementation heavily with varying s
by aidenn0 13y ago
A lot of people underestimate the performance impact of malloc(). It is dog slow. In addition if you use a poor malloc() implementation heavily with varying sized data, you can easily end up using more memory than had you used a copying GC!
- WalterBright 13y agoI've seen a number of compiler "benchmark" programs that inadvertently measured the performance of malloc, not the generated code.
- wicknicks 13y agoVery interesting. Do you have any URLs or papers that go into more depth regarding your statement?
- marshray 13y agomalloc() hasn't been a subject of interest to academics in many decades. This knowledge pre-dates the web in some cases. Do a web search for the replacement allocator used in Firefox. You'll probably find some good discussion there. Plus, every OS, C runtime, and usage pattern is different. YMMV massively depending on everything.
- scott_s 13y agoConcurrent memory allocation had some interest in the past decade - I did work in it, as did some others.
- haberman 13y agoNot only is it slow, many malloc() implementations (like even in glibc, I think) take a global lock, so they are prone to contention when called concurrently. Other mallocs (like tcmalloc and Hoard) satisfy small allocations from a thread-local pool.
- scott_s 13y agoglibc's malloc has actually been decent with regards to concurrent memory allocation for a while now, in my experience. I googled around, and found someone talking about glibc's malloc not using a global lock: http://siddhesh.in/journal/2012/10/24/malloc-per-thread-arenas-in-glibc/ http://siddhesh.in/journal/2012/10/24/malloc-per-thread-aren...
- haberman 13y agoThanks for the info; good to know that glibc has improved in this regard. I'd correct my comment but it's no longer editable. :/