From owner-freebsd-hackers@FreeBSD.ORG Sat Nov 3 20:12:41 2012 Return-Path: Delivered-To: freebsd-hackers@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [69.147.83.52]) by hub.freebsd.org (Postfix) with ESMTP id 72BD01EB for ; Sat, 3 Nov 2012 20:12:41 +0000 (UTC) (envelope-from freebsd@damnhippie.dyndns.org) Received: from duck.symmetricom.us (duck.symmetricom.us [206.168.13.214]) by mx1.freebsd.org (Postfix) with ESMTP id 0B8DC8FC08 for ; Sat, 3 Nov 2012 20:12:34 +0000 (UTC) Received: from damnhippie.dyndns.org (daffy.symmetricom.us [206.168.13.218]) by duck.symmetricom.us (8.14.5/8.14.5) with ESMTP id qA3KCXSO040121 for ; Sat, 3 Nov 2012 14:12:33 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) Received: from [172.22.42.240] (revolution.hippie.lan [172.22.42.240]) by damnhippie.dyndns.org (8.14.3/8.14.3) with ESMTP id qA3KCBE0010197; Sat, 3 Nov 2012 14:12:11 -0600 (MDT) (envelope-from freebsd@damnhippie.dyndns.org) Subject: Re: watchdogd, jemalloc, and mlockall From: Ian Lepore To: d@delphij.net In-Reply-To: <50957793.8060709@delphij.net> References: <1351967919.1120.102.camel@revolution.hippie.lan> <50957793.8060709@delphij.net> Content-Type: text/plain; charset="us-ascii" Date: Sat, 03 Nov 2012 14:12:11 -0600 Message-ID: <1351973531.1120.118.camel@revolution.hippie.lan> Mime-Version: 1.0 X-Mailer: Evolution 2.32.1 FreeBSD GNOME Team Port Content-Transfer-Encoding: 7bit Cc: freebsd-hackers@freebsd.org X-BeenThere: freebsd-hackers@freebsd.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: Technical Discussions relating to FreeBSD List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 03 Nov 2012 20:12:41 -0000 On Sat, 2012-11-03 at 12:59 -0700, Xin Li wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > On 11/3/12 11:38 AM, Ian Lepore wrote: > > In an attempt to un-hijack the thread about memory usage increase > > between 6.4 and 9.x, I'm starting a new thread here related to my > > recent discovery that watchdogd uses a lot more memory since it > > began using mlockall(2). > > > > I tried statically linking watchdogd and it made a small difference > > in RSS, presumably because it doesn't wire down all of libc and > > libm. > > Speaking for this, the last time I brought this up, someone (can't > remember, I think it was phk@) argued that the shared library would > use only one copy of memory, while statically linked ones would be > duplicated and thus use more memory. I haven't yet tried to prove or > challenge that, though. That sounds right to me... if 3 or 4 daemons were to eventually be statically linked because of mlockall(), then each of them would have its own private copy of strlen(), and malloc(), and so on; we'd be back to the bad old days before shared libs came along. Each program would contain its own copy of only the routines from the library that it uses, not the entire library in each program. On the other hand, if even one daemon linked with shared libc uses mlockall(), then all of libc gets wired. As I understand it, only one physical copy of libc would exist in memory, still shared by almost all running apps. The entire contents of the library would continuously occupy physical memory, even the parts that no apps are using. It's hard to know how to weigh the various tradeoffs. I suspect there's no one correct answer. -- Ian