From owner-freebsd-arch Sat Jan 11 3:35:55 2003 Delivered-To: freebsd-arch@freebsd.org Received: from mx1.FreeBSD.org (mx1.freebsd.org [216.136.204.125]) by hub.freebsd.org (Postfix) with ESMTP id 1513237B401; Sat, 11 Jan 2003 03:35:54 -0800 (PST) Received: from HAL9000.homeunix.com (12-233-57-224.client.attbi.com [12.233.57.224]) by mx1.FreeBSD.org (Postfix) with ESMTP id 99E6143F18; Sat, 11 Jan 2003 03:35:53 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: from HAL9000.homeunix.com (localhost [127.0.0.1]) by HAL9000.homeunix.com (8.12.6/8.12.5) with ESMTP id h0BBZpIZ005026; Sat, 11 Jan 2003 03:35:51 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Received: (from das@localhost) by HAL9000.homeunix.com (8.12.6/8.12.5/Submit) id h0BBZp8G005025; Sat, 11 Jan 2003 03:35:51 -0800 (PST) (envelope-from dschultz@uclink.Berkeley.EDU) Date: Sat, 11 Jan 2003 03:35:51 -0800 From: David Schultz To: phk@FreeBSD.ORG Cc: Archie Cobbs , freebsd-arch@FreeBSD.ORG Subject: Re: Virtual memory question Message-ID: <20030111113551.GC3961@HAL9000.homeunix.com> Mail-Followup-To: phk@FreeBSD.ORG, Archie Cobbs , freebsd-arch@FreeBSD.ORG References: <200301110200.h0B20rUC024725@arch20m.dellroad.org> <3788.1042270528@critter.freebsd.dk> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Content-Disposition: inline In-Reply-To: <3788.1042270528@critter.freebsd.dk> Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk List-ID: List-Archive: (Web Archive) List-Help: (List Instructions) List-Subscribe: List-Unsubscribe: X-Loop: FreeBSD.ORG Thus spake 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 #include #include #include #include #include #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