From owner-freebsd-current@FreeBSD.ORG Mon Nov 26 21:07:00 2007 Return-Path: Delivered-To: freebsd-current@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:4f8:fff6::34]) by hub.freebsd.org (Postfix) with ESMTP id D2CA716A469 for ; Mon, 26 Nov 2007 21:07:00 +0000 (UTC) (envelope-from mandrews@bit0.com) Received: from mindcrime.bit0.com (bit0.com [207.246.88.211]) by mx1.freebsd.org (Postfix) with ESMTP id 6EC0C13C508 for ; Mon, 26 Nov 2007 21:07:00 +0000 (UTC) (envelope-from mandrews@bit0.com) Received: from localhost (localhost.bit0.com [127.0.0.1]) by mindcrime.bit0.com (Postfix) with ESMTP id 3B4341E338F for ; Mon, 26 Nov 2007 16:06:56 -0500 (EST) X-Virus-Scanned: amavisd-new at bit0.com Received: from mindcrime.bit0.com ([127.0.0.1]) by localhost (mindcrime.int.bit0.com [127.0.0.1]) (amavisd-new, port 10024) with ESMTP id xQqtTWFHuoAS for ; Mon, 26 Nov 2007 16:06:54 -0500 (EST) Received: from localhost (localhost.bit0.com [127.0.0.1]) (using TLSv1 with cipher DHE-RSA-AES256-SHA (256/256 bits)) (No client certificate requested) by mindcrime.bit0.com (Postfix) with ESMTP for ; Mon, 26 Nov 2007 16:06:54 -0500 (EST) Date: Mon, 26 Nov 2007 16:06:54 -0500 (EST) From: Mike Andrews X-X-Sender: mandrews@mindcrime.int.bit0.com To: freebsd-current@freebsd.org Message-ID: <20071126160422.K82868@mindcrime.int.bit0.com> MIME-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII; format=flowed Subject: vm.pmap.shpgperproc and Apache X-BeenThere: freebsd-current@freebsd.org X-Mailman-Version: 2.1.5 Precedence: list List-Id: Discussions about the use of FreeBSD-current List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Mon, 26 Nov 2007 21:07:00 -0000 (This is about 7.0-BETA3 amd64) Can someone explain to someone who isn't a VM guru exactly what vm.pmap.shpgperproc does? My understanding of how the VM system works isn't great but my understanding is, if you have a process that's malloc'ed, say, 100MB of memory, then it forks, and the child modifies 5MB of it, the total memory usage is really 105MB instead of 200MB because unmodified pages used by both copies are kept as just a single copy; modified pages are copied on write and eventually cause the processes to grow. For example, having mod_perl2 preload and precompile all scripts, instead of doing it on their first hit, should save a ton of memory because the children will share the memory from the parent: http://www.perl.com/pub/a/2002/07/30/mod_perl.html is an old article explaining how I think it works. On a quad-core box with about 200 mod_perl2 Apache processes, and about 2000 other much smaller Apache processes with the mod_perl shut off, I get "Aproaching the limit on PV entries, consider increasing either the vm.pmap.shpgperproc or the vm.pmap.pv_entry_max sysctl" a few times on the console after a reboot. Raising vm.pmap.shpgperproc from the default 200 up to 500 reduces these but doesn't eliminate them. My question is, does vm.pmap.shpgperproc affect how much of the parent's memory a forked child can share, or does it just affect things like SysV SHM where a proces has to explicitly request a shared pool of memory for IPC, or is it something else entirely? Because if it's the former, the default of 200 would mean only 800K memory shared between mod_perl processes which for this situation is absurdly low -- so I hope I'm wrong on how that works. :) Also, what's the danger of setting it too high, on an amd64 system with 4 GB memory (soon to be 6 GB), given the process counts above? I'm attempting to run with it set to 2048 right now and not noticing any ill effects. On amd64 it appears to be tunable at runtime, vs i386 where you have to tweak PMAP_SHPGPERPROC in the kernel config -- very handy. I have found some old discussions about PMAP_SHPGPERPROC on Google but none of the ones I read really get specific enough for me; they all just seem to say "keep raising it til the warnings on the console go away" :) Side question: Anyone know of a way to profile Apache memory usage on a per-module basis?