From owner-freebsd-hackers Sun Sep 8 03:11:29 1996 Return-Path: owner-hackers Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id DAA00502 for hackers-outgoing; Sun, 8 Sep 1996 03:11:29 -0700 (PDT) Received: from who.cdrom.com (who.cdrom.com [204.216.27.3]) by freefall.freebsd.org (8.7.5/8.7.3) with ESMTP id DAA00465 for ; Sun, 8 Sep 1996 03:11:22 -0700 (PDT) Received: from mail.crl.com (mail.crl.com [165.113.1.22]) by who.cdrom.com (8.7.5/8.6.11) with SMTP id DAA00243 for ; Sun, 8 Sep 1996 03:06:48 -0700 (PDT) Received: from parkplace.cet.co.jp by mail.crl.com with SMTP id AA15798 (5.65c/IDA-1.5 for ); Sun, 8 Sep 1996 02:51:24 -0700 Received: from localhost (michaelh@localhost) by parkplace.cet.co.jp (8.7.5/CET-v2.1) with SMTP id JAA09080; Sun, 8 Sep 1996 09:47:59 GMT Date: Sun, 8 Sep 1996 18:47:58 +0900 (JST) From: Michael Hancock To: Terry Lambert Cc: FreeBSD Hackers Subject: Re: namei performance (was Re: FreeBSD vs. Linux 96 (my impressions)) In-Reply-To: Message-Id: Mime-Version: 1.0 Content-Type: TEXT/PLAIN; charset=US-ASCII Sender: owner-hackers@FreeBSD.org X-Loop: FreeBSD.org Precedence: bulk On Sun, 8 Sep 1996, Michael Hancock wrote: > On Fri, 6 Sep 1996, Terry Lambert wrote: > > > > Surprisingly `namei' turned out to be the single biggest contributor to > > > time spent in the kernel. > [snip] > > The namei() call tends to copy the path string around, and so is a > > big offender; this is correctable with a couple of interface changes; > > the nameifree() change drops it about 10%, for instance, by moving > > the alloc/free operation to the same API level, and reducing the > > extra testing that has to go on everywhere in the error cases. > > > > Changing the path string into a pre-parsed list of path components is > > about another 6% win, and you can get another 8% by putting in the > > change to not go through with the allocation on a preexisting element. > > This complicated parsing of symbolic links, since it means you have > > to loop-unroll the mutual recusrsion (which is how symbolic links > > are currently implemented). To avoid using too much kernel stack, > > you have to reduce the stack usage to get there -- another reason > > for a pre-parsed list not allocated on the stack. > > How would it compare to a SYSV lookuppn() which works component by > component? Namei can handle components up to mount boundaries requiring > less calls. I should clarify this. Namei allows the file system dependent layer make the decision to go component by component or by components up to a mount point. nfs_lookup requires component by component, but presumably ufs_lookup can operate on chunks of the pathname up to a mount point. Example: /var/spool/news/comp/unix/bsd/freebsd/misc ^ ^ sd1 sd2 parse pathname into components foreach component (9) VOP_LOOKUP(component[i]) or while pathname not processed (3?) VOP_LOOKUP(pathname) I might be off by one, I'm not entirely clear how many times VOP_LOOKUP gets called in the cases above. Isn't the biggest problem, with the namei way of doing things, the lock put on the directory? A directory will be locked between operations, even if the caller blocks. The directory is locked even for reads which serializes access to the directory. It would be interesting to see if using multiple-reader/single writer locks would improve performance here. Regards, Mike Hancock