tech-userlevel archive

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index][Old Index]

Concurrency and malloc()



I have a question in regard to memory allocation on machines with large 
numbers of concurrent threads.

What is the default malloc() on NetBSD, is it jemalloc?
In the source tree there are:

lib/libc/stdlib/jemalloc.c
lib/libc/stdlib/malloc.c

Are they both part of jemalloc or two different implementations for malloc? If 
they are different, what is malloc.c used for (assuming jemalloc.c provides 
better performance on modern multicore hardware).

Also, assume a situation where multiple threads in a process are allocating 
memory chunks of the same size. Which method do you think would offer better 
performance:

1. Use a general allocator like jemalloc, which has been designed with 
concurrency in mind. Simply call malloc() to allocate memory as needed.

2. Pre-allocate a segment of memory and divide it into equal chunks. This 
might allow for faster memory allocation than jemalloc, since we know all 
chunks are the same size and we can tune the algorithm to execute the least 
number of instructions.


Home | Main Index | Thread Index | Old Index