Date: Sat, 11 Jan 2003 03:35:51 -0800 From: David Schultz <dschultz@uclink.Berkeley.EDU> To: phk@FreeBSD.ORG Cc: Archie Cobbs <archie@dellroad.org>, freebsd-arch@FreeBSD.ORG Subject: Re: Virtual memory question Message-ID: <20030111113551.GC3961@HAL9000.homeunix.com> In-Reply-To: <3788.1042270528@critter.freebsd.dk> References: <200301110200.h0B20rUC024725@arch20m.dellroad.org> <3788.1042270528@critter.freebsd.dk>
next in thread | previous in thread | raw e-mail | index | archive | help
Thus spake phk@FreeBSD.ORG <phk@FreeBSD.ORG>: > In message <200301110200.h0B20rUC024725@arch20m.dellroad.org>, Archie Cobbs wri > tes: > > >The question is: how does the performance of various FreeBSD system > >calls (especially mmap() and munmap()) degrade when a process has > >lots and lots of tiny regions mapped into memory? > > Badly. At least it used to do: When I wrote phkmalloc(3) I tried > using malloc instead of sbrk(2) and it suffered because the VM system ^^^^^^ you mean mmap(2)? > couldn't collapse all the individual allocations (ie: N lines in > /proc/$pid/map The following program does 1000 mmaps of various sizes, then prints its own memory map. It shows that the resulting vm_map has only a few entries in both -CURRENT and -STABLE. The log for src/sys/vm/vm_map.c suggests that the collapse code may have been broken/non-optimal at several times during the past six years. #include <sys/types.h> #include <sys/mman.h> #include <err.h> #include <fcntl.h> #include <stdio.h> #include <unistd.h> #define NUM_MMAPS 1000 int main() { int i, psize, fd, len; char *p; char buf[20]; psize = getpagesize(); for (i = 0; i < NUM_MMAPS; i++) { p = mmap(NULL, psize * (i % 4 + 1), PROT_READ|PROT_WRITE, MAP_ANON|MAP_SHARED, -1, 0); if (p == NULL) err(1, "mmap"); } snprintf(buf, 20, "/proc/%u/map", getpid()); if ((fd = open(buf, O_RDONLY)) < 0) err(1, "open"); if ((len = read(fd, p, psize - 1)) < 0) err(1, "read"); p[len] = '\0'; printf("%s\n", p); return 0; } To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20030111113551.GC3961>