Skip site navigation (1)Skip section navigation (2)
Date:      Sat, 12 Nov 2011 17:28:59 +0100
From:      Pawel Jakub Dawidek <pjd@FreeBSD.org>
To:        Peter Wemm <peter@wemm.org>
Cc:        Ed Schouten <ed@80386.nl>, arch@freebsd.org
Subject:   Re: The strangeness called `sbin'
Message-ID:  <20111112162858.GA29868@garage.freebsd.pl>
In-Reply-To: <CAGE5yCqMcHwAhXKbyEH6vUR=N14tCjkgX=RMJTdq-po92GcOMQ@mail.gmail.com>
References:  <20111110123919.GF2164@hoeg.nl> <CAGE5yCr3BzWzwOAqo7wifgUTRC%2BG=2o4bDmk9H-%2BCxr=zJqYmw@mail.gmail.com> <20111110171605.GI2164@hoeg.nl> <CAGE5yCqMcHwAhXKbyEH6vUR=N14tCjkgX=RMJTdq-po92GcOMQ@mail.gmail.com>

next in thread | previous in thread | raw e-mail | index | archive | help

--zYM0uCDKw75PZbzx
Content-Type: text/plain; charset=iso-8859-1
Content-Disposition: inline
Content-Transfer-Encoding: quoted-printable

On Thu, Nov 10, 2011 at 09:33:21AM -0800, Peter Wemm wrote:
> On Thu, Nov 10, 2011 at 9:16 AM, Ed Schouten <ed@80386.nl> wrote:
> > Hi Peter,
> >
> > * Peter Wemm <peter@wemm.org>, 20111110 17:56:
> >> Of course, that pales in comparison to the impact of adding
> >> /usr/local/bin to the path, but it does show this does have potential
> >> user visibility. =A0And there's also the issue that most most users add
> >> every possible directory to their $PATH anyway.
> >
> > Exactly. Also, there are shells nowadays that cache all binaries in PATH
> > up front, such as zsh. When they start, they loop through all dirents in
> > all directories in $PATH and add it to a big cache. This entirely
> > defeats this purpose.
>=20
> I use tcsh and zsh, I'm aware of this cache.
>=20
> However, libc doesn't, so things like /bin/sh when running shell
> scripts do not.  make(1) does not.  People do still care about
> buildworld time.  Simple things like changing gcc to static linking
> were a few percentage points of buildworld time, back in the day.
> Having /bin/sh as a static binary used to be 3%-5% of buildworld time,
> simply because fork/exec was faster as the copy-on-write burden was
> less.  This stuff adds up.

Peter, are you sure that one big directory is worse than many smaller
directories for lookup?

If we have many small directories the shell would do the following:

	execve("/bin/cmd")
	execve("/usr/bin/cmd")
	execve("/sbin/cmd")
	execve("/usr/sbin/cmd")

With one small directory it will do only one execve(2).

Neither ZFS nor UFS (at least with dirhash, which is the default)
doesn't implement lookup as readdir of entire directory and strcmp() in
a loop. Things are better organized and lookups are not O(n).

When you have more directories you have to pay price of multiple lookups
and multipe system calls, which for me seems much more expensive.

--=20
Pawel Jakub Dawidek                       http://www.wheelsystems.com
FreeBSD committer                         http://www.FreeBSD.org
Am I Evil? Yes, I Am!                     http://yomoli.com

--zYM0uCDKw75PZbzx
Content-Type: application/pgp-signature

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v2.0.14 (FreeBSD)

iEYEARECAAYFAk6+nsoACgkQForvXbEpPzQYygCfXewt4uEJ9e10zo9zzVI7swrv
9p8AnRyVQ7o7+HXp4v4zu51L0Cs9k2zq
=w+14
-----END PGP SIGNATURE-----

--zYM0uCDKw75PZbzx--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?20111112162858.GA29868>