I saw mmap() syscalls every time when malloc() was used.
This statement is similar in spirit to saying "There's no way to get to work today" - it only makes sense when lots of context is known. You'd have to disclose the exact benchmark you were using, glibc
version, distro, etc. I'm pretty sure that if you're allocating lots of small objects (e.g. 16-32 bytes), you will not be seeing mmap()
on every call.
Syscalls are performance hogs when compared to "limited" operations on data structures, so malloc()
would perform very poorly if it really always invoked mmap()
, no matter the circumstances. Sure, if you were always calling it like malloc(1024)
, then yes, it may end up mmap()
-ing often.
And you'd also want to see what sort of mmap()
arguments were passed.
So, all I see here is that your benchmark somehow is skewed against you :)