Some mmap observations compared to Linux 2.6/OpenBSD

David Schultz das at FreeBSD.ORG
Sat Oct 25 23:56:52 PDT 2003


On Sun, Oct 26, 2003, Mike Silbersack wrote:
> 
> On Sat, 25 Oct 2003, David Schultz wrote:
> 
> > But regardless of the approach, someone has yet to demonstrate
> > that this is actually a performance problem in the real world. ;-)
> 
> I could be way wrong, but I would think that a database might mmap
> discontiguous segments of memory.  Perhaps someone familiar with
> mysql/postgres/others might know if they would be a good benchmark.

I'm not particularly ``familiar'' with postgres, but I did some
performance tests on it a little while ago.  Grepping through one
of the traces just now, I found that database system made 139
calls to mmap(), and the maximum number of regions mapped at any
given time was 39.[1]  I don't have execution times for the mmap()
calls in this trace anymore, but with 139 of them total, I'm sure
the overhead is minimal.  Nevertheless, it's certainly possible
that a reasonable ``mmap-bound'' application could exist; I just
don't think it's very likely.

> Actually, relating to this, didn't phk request a VM function which would
> remap a page (or contiguous segment of pages) to a new address which had
> free space after it?  I believe that he needed such a feature to
> turbocharge realloc().  It sounds like the freelist mode of operation
> would make that more feasible.

What he requested (at least in the malloc.c comments) was the
ability to do a virtual move of malloc's main directory so that it
can be expanded without copying it to a new location.  You can't
do this with mmap() because there's no ``handle'' with which to
refer to anonymous memory regions from userland, and there are
problems with malloc using a file descriptor.  In any case, this
issue is orthogonal, since malloc only needs one such directory at
a time.


[1] This is very approximate because it doesn't count shared
    libraries, and the little awk script I wrote doesn't account
    for the possibility that postgres might unmap a smaller region
    than the one it mapped.


More information about the freebsd-hackers mailing list