From owner-freebsd-current@FreeBSD.ORG Fri Aug 29 20:21:51 2008 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 27A62106568B for ; Fri, 29 Aug 2008 20:21:51 +0000 (UTC) (envelope-from peter@wemm.org) Received: from wf-out-1314.google.com (wf-out-1314.google.com [209.85.200.174]) by mx1.freebsd.org (Postfix) with ESMTP id 012DA8FC24 for ; Fri, 29 Aug 2008 20:21:50 +0000 (UTC) (envelope-from peter@wemm.org) Received: by wf-out-1314.google.com with SMTP id 24so930389wfg.7 for ; Fri, 29 Aug 2008 13:21:50 -0700 (PDT) Received: by 10.142.47.6 with SMTP id u6mr1098108wfu.300.1220041310513; Fri, 29 Aug 2008 13:21:50 -0700 (PDT) Received: by 10.142.76.14 with HTTP; Fri, 29 Aug 2008 13:21:50 -0700 (PDT) Message-ID: Date: Fri, 29 Aug 2008 13:21:50 -0700 From: "Peter Wemm" To: "John Baldwin" In-Reply-To: <200808291140.30158.jhb@freebsd.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 7bit Content-Disposition: inline References: <20080826124335.GD3305@carrot.paeps.cx> <20080827161940.1b4403ee@peedub.jennejohn.org> <200808291140.30158.jhb@freebsd.org> Cc: freebsd-current@freebsd.org Subject: Re: Enormous utmp since mpsafetty 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: Fri, 29 Aug 2008 20:21:51 -0000 On Fri, Aug 29, 2008 at 8:40 AM, John Baldwin wrote: > On Wednesday 27 August 2008 10:19:40 am Gary Jennejohn wrote: >> On Wed, 27 Aug 2008 12:50:17 +0100 (BST) >> Robert Watson wrote: >> >> > On Wed, 27 Aug 2008, Ollivier Robert wrote: >> > >> > > According to Gary Jennejohn: >> > >> There are many more pseudo-ttys in /etc/ttys now. AFAIK utmp allocates > an >> > >> entry for every one of them at startup. >> > > >> > > utmp concepts are ancient. It is indexed by the tty/pty number so can > grow >> > > rather large but it should be a sparse one too. I remember talks about >> > > replacing it with something a bit more modern. Backward compatibility > is >> > > assured through login(3) although it would break programs digging in the >> > > utmp file itself. SVR4 had utmp/utmpx and setutline/getutline BTW... >> > >> > Right -- utmp growing to 256K would be an excellent example of utmp format >> > inefficiency. On the other hand, utmp growing to 998M is probably an > example >> > of a bug rather than an inefficient design. freefall.FreeBSD.org, a >> > relatively busy shell box, has a utmp of around 5k, so common use doesn't >> > generally exercise that inefficiency... >> > >> >> But freefall is running FreeBSD 7.0-STABLE #34: Sat Apr 12, so it doesn't >> have the new tty stuff running, although I don't suppose that completely >> explains the gigantic utmp which OT reported. > > The new pts entries are after all the 256 pty entries in /etc/ttys, so utmp > may be larger becuase the pts entries are "later" in the file (higher > offsets). However, if the file is sparse, then it doesn't actually hurt > anything. Maybe so, but sizeof(struct utmp) is 44 bytes. The OP reported a utmp of 998MB. The utmp slot is given by ttyslot(3), which looks up /etc/ttys. If everything was working right, there would have to be roughly 24 million lines in /etc/ttys for ttyslot() to cause a seek/write this high up. Something obviously didn't go right. On that note.. who wants to do utmp.db using the sysv/posix compatible utmp/utmpx API to access it? Fixed index slots should have died 10+ years ago. (getttyent(3) also handles the 'secure' flag, which is another pretty outdated concept these days) -- Peter Wemm - peter@wemm.org; peter@FreeBSD.org; peter@yahoo-inc.com; KI6FJV "All of this is for nothing if we don't go to the stars" - JMS/B5 "If Java had true garbage collection, most programs would delete themselves upon execution." -- Robert Sewell